webpack打包less文件的時候出現了以下錯誤 :
ERROR in ./node_modules/[email protected]@antd/lib/button/style/index.less (./node_modules/[email protected]@css-loader/dist/cjs.js!./node_modu
les/[email protected]@less-loader/dist/cjs.js!./node_modules/[email protected]@antd/lib/button/style/index.less)
Module build failed (from ./node_modules/[email protected]@less-loader/dist/cjs.js):
// https://github.com/ant-design/ant-motion/issues/44
.bezierEasingMixin();
^
Inline JavaScript is not enabled. Is it set in your options?
Error in ~/landing/node_modules/[email protected]@antd/lib/style/color/bezierEasing.less (line 110, column 0)
@ ./node_modules/[email protected]@antd/lib/button/style/index.less 2:26-159
@ ./node_modules/[email protected]@antd/lib/button/style/index.js
@ ./src/Banner3.jsx
@ ./src/index.jsx
@ ./src/index.js
解決
-
根據錯誤提示,訪問了https://github.com/ant-design/ant-motion/issues/44
-
按照大佬們的回到,在less-loader下面加上optipns
{ loader: 'less-loader', options: { javascriptEnabled: true } }
-
但是實測發現,依然會報錯
ERROR in ./node_modules/[email protected]@antd/lib/grid/style/index.less (./node_modules/[email protected]@css-loader/dist/cjs.js!./node_modules/[email protected]@less-loader/dist/cjs.js??ref--4-2!./node_modules/[email protected]@antd/lib/grid/style/index.less)
Module build failed (from ./node_modules/[email protected]@less-loader/dist/cjs.js):
ValidationError: Invalid options object. Less Loader has been initialized using an options object that does not match the API schema.
- options has an unknown property 'javascriptEnabled'. These properties are valid:
object { lessOptions?, prependData?, appendData?, sourceMap?, implementation? }
at validate (/home/lxx/tmp/react/landing/node_modules/[email protected]@schema-utils/dist/validate.js:96:11)
at Object.lessLoader (/home/lxx/tmp/react/landing/node_modules/[email protected]@less-loader/dist/index.js:22:28)
@ ./node_modules/[email protected]@antd/lib/grid/style/index.less 2:26-169
@ ./node_modules/[email protected]@antd/lib/grid/style/index.js
@ ./node_modules/[email protected]@antd/lib/row/style/index.js
@ ./src/Content0.jsx
@ ./src/index.jsx
@ ./src/index.js
-
最終在網上查找到了最正確的答案,將options的代碼改爲
{ loader: 'less-loader', options: { lessOptions: { javascriptEnabled: true } } }