webpack打包less出错

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

解决

  1.    根据错误提示,访问了https://github.com/ant-design/ant-motion/issues/44
    
  2.  按照大佬们的回到,在less-loader下面加上optipns
    
  		{
  				loader: 'less-loader',
  				options: {
  						javascriptEnabled: true      
  		    	}
  		}
  1.  但是实测发现,依然会报错
    
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
  1.  最终在网上查找到了最正确的答案,将options的代码改为
    
  		{
  				loader: 'less-loader',
  				options: {
  						lessOptions: {
  								javascriptEnabled: true
  						}      
  		    	}
  		}

你可能感兴趣的:(前端,webpack,less,js)