react+antd报错.bezierEasingMixin()
dearweb 发布:2021-09-30 15:13:29阅读:环境create-react-app4.x + antd4.x
报错的提示见下面代码
./node_modules/antd/lib/button/style/index.less (./node_modules/css-loader??ref--6-oneOf-7-1!./node_modules/postcss-loader/src??postcss!./node_modules/less-loader/dist/cjs.js!./node_modules/antd/lib/button/style/index.less) // https://github.com/ant-design/ant-motion/issues/44 .bezierEasingMixin(); ^ Inline JavaScript is not enabled. Is it set in your options? in /myproject/react/antedemo/node_modules/antd/lib/style/color/bezierEasing.less (line 110, column 0)
上面的错误是说没有设置 javascriptEnabled: true
下面我们设置一下 javascriptEnabled: true记住是在这里地址文件里面
./node_modules/less-loader/dist/utils.js 里面的这个地方加入这行代码
function getLessOptions(loaderContext, loaderOptions) { const options = (0, _clone.default)(loaderOptions.lessOptions ? typeof loaderOptions.lessOptions === 'function' ? loaderOptions.lessOptions(loaderContext) || {} : loaderOptions.lessOptions : {}); const lessOptions = { plugins: [], relativeUrls: true, // 在这个位置添加这行代码============================================== javascriptEnabled: true, // We need to set the filename because otherwise our WebpackFileManager will receive an undefined path for the entry filename: loaderContext.resourcePath, ...options }; lessOptions.plugins.unshift(createWebpackLessPlugin(loaderContext)); const useSourceMap = typeof loaderOptions.sourceMap === 'boolean' ? loaderOptions.sourceMap : loaderContext.sourceMap; if (useSourceMap) { lessOptions.sourceMap = { outputSourceFiles: true }; } return lessOptions;}
最后重启下服务,就一切ok了。
小礼物走一波,支持作者
赏还没有人赞赏,支持一波吧