React Webpack无效的选项对象。 CSS Loader已使用options对象初始化

嗨,我尝试退出我的webpack的人可能会通过 bottomNavigationBar: BottomNavigationBar( unselectedItemColor: Colors.green,selectedItemColor: Colors.yellow,items:[ new BottomNavigationBarItem(icon:Icon(Icons.add_shopping_cart)) ] 创建-反应应用

然后在npm run eject 内搜索该部分:

config/webpack.config.js

我打算改用CSS模块的地方。因此,请替换选项中的某些设置:

 isEnvDevelopment && require.resolve('style-loader'),isEnvProduction && {
        loader: MiniCssExtractPlugin.loader,// css is located in `static/css`,use '../../' to locate index.html folder
        // in production `paths.publicUrlOrPath` can be a relative path
        options: paths.publicUrlOrPath.startsWith('.')
          ? { publicPath: '../../' }
          : {},},{
        loader: require.resolve('css-loader'),options: cssOptions,

但是这没有用。通常,webpack具有两个配置loader: require.resolve('css-loader'),options: { importLoaders: 1,modules: true,// This will generate these unique CSS files // once we import them from the object localIdentName: '[name]__[local]__[hash:base64:5]' } } webpack.config.dev.js。最后,它输出此错误:

webpack.config.production.js

有什么解决方法吗?

您可以在此处检查整个Webpack文件:https://jsfiddle.net/15z2v9ju/

iCMS 回答:React Webpack无效的选项对象。 CSS Loader已使用options对象初始化

根据您的评论,我建议在当前使用的功能getStyleLoaders中查找并添加更多选项:

getStyleLoaders({
  importLoaders: 1,modules: {
    localIdentName: '[name]__[local]__[hash:base64:5]'
  },})
                 

但是,您的配置似乎旧了。 localIdentName个选项似乎已移至modules

本文链接:https://www.f2er.com/1788572.html

大家都在问