vue-cli3 vue.config.js 配置

 1 // cli_api配置地址 https://cli.vuejs.org/zh/config/
 2 module.exports = {
 3     baseUrl: './', // 部署应用包时的基本 URL
 4     outputDir: 'dist', // build 时生成的生产环境构建文件的目录
 5     // assetsDir: '', // 放置生成的静态资源 (js、css、img、fonts) 的 (相对于 outputDir 的) 目录
 6     indexPath: 'index.html', // 指定生成的 index.html 的输出路径 (相对于 outputDir)
 7     filenameHashing: true, // 文件名哈希
 8     lintOnSave: true, // eslint-loader 是否在保存的时候检查
 9     runtimeCompiler: true,// 设置为 true 后你就可以在 Vue 组件中使用 template 选项
10     productionSourceMap: false,// 是否需要生产环境的 source map
11     css: {
12         sourceMap: false, // 是否为 CSS 开启 source map
13     },
14     devServer: { // 所有 webpack-dev-server 的选项都支持
15         hot: true, // 热更新
16         open: true,
17         host: '0.0.0.0',
18         port: 8888,
19         https: false,
20         hotOnly: false,
21         // proxy: {}, // 跨域代理
22     },
23     parallel: require('os').cpus().length > 1, // 该选项在系统的 CPU 有多于一个内核时自动启用,仅作用于生产构建
24     pwa: {}, // PWA 插件相关配置 see => https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-pwa
25     pluginOptions: {}, // 第三方插件配置
26     configureWebpack: {
27         module: {
28             rules: [ // 可在package.json 配置顶层 sideEffects: false
29                 {
30                     test: /\.(js|jsx|vue)?$/,
31                     sideEffects: false // false | [] -> []放置不清除副作用文件
32                 }
33             ]
34         },
35         externals: { // 在这里配置后,减少了压缩的包内容,需要在public/index.html通过cdn方式再引入,注意对应的版本
36             vue: "Vue",
37             vuex: "Vuex",
38             "vue-router": "VueRouter",
39             "element-ui": "ELEMENT"
40         }
41     }
42 }
转载@:https://github.com/ZTrainWilliams/vue_cli3.0.5

猜你喜欢

转载自www.cnblogs.com/hktx/p/10767483.html