Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.0k views
in Technique[技术] by (71.8m points)

vue-cli3新建的项目运行提示webpack 的性能警告

因为是新建的项目没啥东西,只有一个页面,还有html里用cdn引入了几个库,但是为啥会报webpack的性能警告呢?警告如下:
image
我的vue.config.js的配置项如下:

module.exports = {
  publicPath: '/datav-project/',
  assetsDir: 'static',
  devServer: {
    host: "0.0.0.0",
    port: 9527, // 端口号
    https: false, // https:{type:Boolean}
    open: true,
    // hotOnly: true, // 热更新
    proxy: { //配置自动启动浏览器
      '/api': {
        target: process.env.VUE_APP_BASE_API, //process.env.BASE_API,
        changeOrigin: true, //允许跨域,如果接口跨域,需要进行这个参数配置
        secure: false, //如果是https接口,需要配置这个参数
      }
    }
  },
  lintOnSave: false,
  configureWebpack: (config) => {
    //防止将第三方引入的包比如cdn引入的文件打包到 bundle 中,而是在运行时(runtime)再去从外部获取这些扩展依赖
    config.externals = {
      'vue': 'Vue',
      'vue-router': 'VueRouter',
      'axios': 'axios',
      'echarts': 'echarts',
      'js-cookie': 'Cookies'
    }
  },
  chainWebpack (config) {
    config.resolve.symlinks(true); // 修复热更新失效
    config.plugins.delete('preload') // TODO: need test
    config.plugins.delete('prefetch') // TODO: need test
    config.resolve.alias.set('src', resolve('src'))
    config.plugin('compressionPlugin')
      .use(new CompressionPlugin({
        test: /.js$|.html$|.css/, // 匹配文件名
        threshold: 1024, // 对超过10k的数据压缩
        deleteOriginalAssets: false // 不删除源文件
      }))
  }
};

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

webpack-bundle-analyzer 插件分析一下


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...