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
  						}      
  		    	}
  		}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章