const path = require('path') function 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, sourceMap: false, // requireModuleExtension: true, loaderOptions: { sass: { prependData: `@import "@/assets/css/variable.scss";` } } }, chainWebpack: config => { config.plugin('html').tap(args => { args[0].title = '黑龙江省哈尔滨市2024年老旧小区改造项目EPC工程总承包(七标段)' return args }) // 配置别名 config.resolve.alias.set('@', resolve('src')).set('assets', resolve('src/assets')).set('components', resolve('src/components')).set('views', resolve('src/views')).set('api', resolve('src/api')) if (process.env.NODE_ENV === 'production') { // 删除系统默认的splitChunk config.optimization.delete('splitChunks') } }, 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 }, 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: { proxy: { '/x_program_center': { target: 'http://www.harbinxiaoshi.cn:8000', pathRewrite: { '^/x_program_center': '' } } } } }