| | |
| | | /* |
| | | * @Author: daidai |
| | | * @Date: 2021-11-22 14:57:15 |
| | | * @LastEditors: Please set LastEditors |
| | | * @LastEditTime: 2022-04-29 15:12:50 |
| | | */ |
| | | const path = require("path"); |
| | | function resolve(dir) { |
| | | return path.join(__dirname, dir); |
| | | const path = require('path') |
| | | const resolve = dir => { |
| | | return path.join(__dirname, dir) |
| | | } |
| | | |
| | | module.exports = { |
| | | publicPath: './', |
| | | outputDir: process.env.VUE_APP_outputDir || 'dist', |
| | | assetsDir: 'static', |
| | | filenameHashing: true, |
| | | lintOnSave: false, |
| | | runtimeCompiler: false, |
| | | transpileDependencies: [], |
| | | productionSourceMap: false, |
| | | css: { |
| | | // æ¯å¦ä½¿ç¨csså离æä»¶ ExtractTextPlugin |
| | | extract: process.env.NODE_ENV === "production" ? true : false,//æ¯å¦å°ç»ä»¶ä¸ç CSS æåè³ä¸ä¸ªç¬ç«ç CSS æä»¶ä¸ (è䏿¯å¨ææ³¨å
¥å° JavaScript ä¸ç inline 代ç )ã |
| | | sourceMap: false,//æ¯å¦ä¸º CSS å¼å¯ source mapã设置为 true ä¹åå¯è½ä¼å½±åæå»ºçæ§è½ã |
| | | loaderOptions: { |
| | | sass: { |
| | | prependData: `@import "@/assets/css/variable.scss";` |
| | | } |
| | | }, |
| | | requireModuleExtension: true, |
| | | }, |
| | | |
| | | chainWebpack: (config) => { |
| | | // é
ç½®å«å |
| | | config.resolve.alias |
| | | .set('@', resolve('src')) |
| | | .set('assets', resolve('src/assets')) |
| | | .set('assetsBig', resolve('src/pages/big-screen/assets')) |
| | | .set('components', resolve('src/components')) |
| | | .set('views', resolve('src/views')) |
| | | .set('api', resolve('src/api')) |
| | | .set('lib', resolve('src/lib')) |
| | | |
| | | if (process.env.NODE_ENV === "production") { |
| | | // å é¤ç³»ç»é»è®¤çsplitChunk |
| | | config.optimization.delete("splitChunks"); |
| | | } |
| | | // å é¤é¢å è½½ |
| | | // // ç§»é¤ prefetch æä»¶ |
| | | // config.plugins.delete('prefetch-index') |
| | | // // ç§»é¤ preload æä»¶ |
| | | // config.plugins.delete('preload-index'); |
| | | // config.optimization.minimizer('terser').tap((args) => { |
| | | // // å»é¤ç产ç¯å¢console |
| | | // args[0].terserOptions.compress.drop_console = true |
| | | // return args |
| | | // }) |
| | | }, |
| | | configureWebpack: config => { |
| | | // ç»è¾åºçjsåç§°æ·»å hash |
| | | config.output.filename = "static/js/[name].[hash].js"; |
| | | config.output.chunkFilename = "static/js/[name].[hash].js"; |
| | | config.optimization = { |
| | | splitChunks: { |
| | | cacheGroups: { |
| | | // æ½ç¦»ææå
¥å£çå
¬ç¨èµæºä¸ºä¸ä¸ªchunk |
| | | common: { |
| | | name: "chunk-common", |
| | | chunks: "initial", |
| | | minChunks: 2, |
| | | maxInitialRequests: 5, |
| | | minSize: 0, |
| | | priority: 1, |
| | | reuseExistingChunk: true, |
| | | enforce: true |
| | | }, |
| | | // æ½ç¦»node_modulesä¸çåºä¸ºä¸ä¸ªchunk |
| | | // vendors: { |
| | | // name: "chunk-vendors", |
| | | // test: /[\\/]node_modules[\\/]/, |
| | | // chunks: "initial", |
| | | // priority: 2, |
| | | // reuseExistingChunk: true, |
| | | // enforce: true |
| | | // }, |
| | | element: { |
| | | name: "chunk-element-ui", |
| | | test: /[\\/]node_modules[\\/]element-ui[\\/]/, |
| | | chunks: "all", |
| | | priority: 3, |
| | | reuseExistingChunk: true, |
| | | enforce: true |
| | | }, |
| | | yhhtUi: { |
| | | name: "chunk-yhht-ui", |
| | | test: /[\\/]node_modules[\\/]yhht-ui[\\/]/, |
| | | chunks: "all", |
| | | priority: 4, |
| | | reuseExistingChunk: true, |
| | | enforce: true |
| | | }, |
| | | datav: { |
| | | name: "chunk-datav", |
| | | test: /[\\/]node_modules[\\/]@jiaminghi[\\/]data-view[\\/]/, |
| | | chunks: "all", |
| | | priority: 4, |
| | | reuseExistingChunk: true, |
| | | enforce: true |
| | | }, |
| | | } |
| | | } |
| | | }; |
| | | }, |
| | | // æ¯å¦ä¸º Babel æ TypeScript ä½¿ç¨ thread-loaderã该é项å¨ç³»ç»ç CPU æå¤äºä¸ä¸ªå
æ ¸æ¶èªå¨å¯ç¨ï¼ä»
ä½ç¨äºç产æå»ºã |
| | | parallel: require('os').cpus().length > 1, |
| | | devServer: { |
| | | // '/api':{ |
| | | // target: 'http://192.168.8.211:8098/', |
| | | // // è·¨åé
ç½® |
| | | // changeOrigin: true, |
| | | // // è·¯å¾éå |
| | | // pathRewrite:{ |
| | | // '^/api': '/' |
| | | // } |
| | | // } |
| | | host:'0.0.0.0', |
| | | port:8090 |
| | | }, |
| | | pluginOptions: { |
| | | } |
| | | chainWebpack: config => { |
| | | config.resolve.alias |
| | | .set('_c', resolve('src/components')) // key,valueèªè¡å®ä¹ï¼æ¯å¦.set('@@', resolve('src/components')) |
| | | }, |
| | | lintOnSave: false |
| | | } |