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