const { defineConfig } = require("@vue/cli-service"); const timestamp = new Date().getTime(); //生产环境标记 const IS_PRODUCTION = process.env.NODE_ENV === "production"; // 生产配置 const cdn_production = { js: ["/librarys/vue@2.6.11/vue.min.js"] }; // 开发配置 const cdn_development = { js: ["/librarys/vue@2.6.11/vue.js"] }; module.exports = defineConfig({ lintOnSave: false, productionSourceMap: !IS_PRODUCTION, //打包不生成map文件 devServer: { open: false }, css: { extract: IS_PRODUCTION ? { filename: `css/[name].${timestamp}.css`, chunkFilename: `css/[name].${timestamp}.css` } : false, loaderOptions: { less: { lessOptions: { javascriptEnabled: true } } } }, configureWebpack: { output: { filename: `js/[name].${timestamp}.js`, chunkFilename: `js/[name].${timestamp}.js` }, // 排除不引用 externals: { vue: "Vue", "vue-router": "VueRouter", axios: "axios", "view-design": "iview" } }, chainWebpack: (config) => { config.plugin("html").tap((args) => { args[0].cdn = IS_PRODUCTION ? cdn_production : cdn_development; return args; }); } });