webpack建议*~entryin./node_modules/@vue/cli-service/lib/commands/build/

原创
小哥 3年前 (2022-11-16) 阅读数 10 #大杂烩

一小时后 虽然我不知道为什么,但我知道是谁在作怪。

 Object.assign(config.resolve, {
        alias: {
           "@": path.resolve(__dirname, "./src"),
           components: path.resolve(__dirname, "./src/components"),
        },
  });

以上在configureWebpack通过将错误更改为以下内容,可以解决中设置的地址别名

直接修改

    config.resolve.alias["@"] = resolve("src");
    config.resolve.alias["components"] = resolve("src/components");

完整配置:

 configureWebpack: (config) => {
    // 开启gzip压缩
    config.plugins.push(
      new CompressionWebpackPlugin({
        filename: (info) => {
          return ${info.path}.gz${info.query};
        },
        algorithm: "gzip",
        threshold: 10240, // 仅处理大小大于此值的资源。 10240
        test: new RegExp("\.(" + productionGZipExtensions.join("|") + ")$"),
        minRatio: 0.8, // 仅处理压缩率小于此值的资源。
        deleteOriginalAssets: false, // 删除原始文件
      })
    );
    // webpack包装体积的性能提示
    config["performance"] = {
      maxEntrypointSize: 50000000,
      maxAssetSize: 30000000,
    };
    // 开发生产通用配置别名
    // Object.assign(config.resolve, {
    //   alias: {
    //     "@": path.resolve(__dirname, "./src"),
    //     components: path.resolve(__dirname, "./src/components"),
    //   },
    // });

    config.resolve.alias["@"] = resolve("src");
    config.resolve.alias["components"] = resolve("src/components");
  },
版权声明

所有资源都来源于爬虫采集,如有侵权请联系我们,我们将立即删除