Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configureWebpack 配置报错 module.rules.push, plugins.push #59

Open
haiting opened this issue Nov 24, 2022 · 0 comments
Open

configureWebpack 配置报错 module.rules.push, plugins.push #59

haiting opened this issue Nov 24, 2022 · 0 comments

Comments

@haiting
Copy link

haiting commented Nov 24, 2022

代码:

configureWebpack(webpackConfig) {
    if (process.env.NO_CHUNK === 'false' || !disableDynamicImport) {
      // 配置第三方依赖包入口
      webpackConfig.entry.vendor = Object.keys(packageJson.dependencies); // 获取生产环境依赖库
      // 配置 chunk 输出的文件命名格
      webpackConfig.output.chunkFilename = fileName;
    }
    Object.assign(webpackConfig, {
      entry: {
        app: ['babel-polyfill', './src/main.js']
      },
      name: name,
      // 开发生产共同配置
      resolve: {
        alias: {
          '@': path.resolve(__dirname, './src')
          // '@c': path.resolve(__dirname, './src/components'),
          // '@p': path.resolve(__dirname, './src/pages')
        } // 别名配置
      }
    });

    webpackConfig.module.rules.push({
      test: /\.js$/,
      loader: 'babel-loader',
      include: [path.resolve('node_modules/vcolorpicker')]
    });
    webpackConfig.module.rules.push({
      test: /\.mjs$/,
      include: /node_modules/,
      type: 'javascript/auto'
    });
    webpackConfig.plugins.push(
      new AntDesignThemePlugin(options),
      // 收集项目信息插件
      new SinobestGatherProjectInfo()
    );

error when starting dev server: TypeError: Cannot read properties of undefined (reading 'rules')
error when starting dev server: TypeError: Cannot read properties of undefined (reading 'push')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant