IndexXuan / vue-cli-plugin-vite

Use vite today, with vue-cli.

Home Page:https://github.com/IndexXuan/vue-cli-plugin-vite

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

haiting opened this issue · comments

代码:

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')