const webpack = require('webpack') const path = require('path'); function resolve (dir) { return path.join(__dirname, dir) } // 项目的主要配置文件 module.exports = { publicPath: '', outputDir: './dist', productionSourceMap: false, lintOnSave: false, //启用并行化 默认并发运行数 os.cpus().length - 1 ,并行化可以显著加速构建 parallel: require('os').cpus().length > 1, configureWebpack: { plugins: [ new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery', 'windows.jQuery': 'jquery', 'window.Quill': 'quill/dist/quill.js', 'Quill': 'quill/dist/quill.js' }), ] }, chainWebpack: (config)=>{ //修改文件引入自定义路径 config.resolve.alias .set('@', resolve('src')) config.resolve.alias .set('@utils', resolve('src/utils')) }, pages: { index: { // 页面入口 entry: 'src/main.js', // 模板来源 template: 'public/index.html', // 在 dist/index.html 的输出 filename: 'index.html', // 当使用 title 选项时, // template 中的 title 标签需要是 <%= htmlWebpackPlugin.options.title %> title: '重庆市市级生态环境监测专家库管理系统', // 在这个页面中包含的块,默认情况下会包含提取出来的通用 chunk 和 vendor chunk chunks: ['chunk-vendors', 'chunk-common', 'index'] }, // 当使用只有入口的字符串格式时, // 模板会被推导为 `public/subpage.html` // 并且如果找不到的话,就回退到 `public/index.html` // 输出文件名会被推导为 `subpage.html` subpage: 'src/main.js' }, css: { // 是否使用css分离插件 //生产环境下是 true,开发环境下是 false extract: false, // 开启 CSS source maps? sourceMap: false, // css预设器配置项 loaderOptions: {}, // 启用 CSS modules requireModuleExtension: true, }, devServer: { // 接口反向代理 open: false, port: 8028, /*proxy: { // 单位管理接口 "/api": { target: process.env.VUE_APP_URL, changeOrigin: true, // ws: true, // proxy websockets pathRewrite: { "^/api": "" } } }*/ } }