123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- const path = require('path')
- const minify = process.env.NODE_ENV === 'development' ? false : {
- collapseWhitespace: true,
- removeComments: true,
- removeRedundantAttributes: true,
- removeScriptTypeAttributes: true,
- removeStyleLinkTypeAttributes: true,
- useShortDoctype: true,
- minifyCSS: true,
- minifyJS: true
- }
- function resolve(dir) {
- return path.join(__dirname, dir)
- }
- module.exports = {
- publicPath: '/',
- lintOnSave: true,
- runtimeCompiler: true,
- pages: {
- index: {
- entry: 'src/main.js',
- template: 'public/index.html',
- filename: 'index.html',
- chunks: ['chunk-vendors', 'chunk-common', 'index'],
- minify
- },
- preview: {
- entry: 'src/views/preview/main.js',
- template: 'public/preview.html',
- filename: 'preview.html',
- chunks: ['chunk-vendors', 'chunk-common', 'preview'],
- minify
- }
- },
- pluginOptions: {
- 'style-resources-loader': {
- preProcessor: 'less',
- patterns: [
- path.resolve(__dirname, './src/styles/variables.less')
- ]
- }
- },
- devServer: {
- proxy: {
- '/api': {
- target: 'https://wy-test.huiguanjia.cn/9ad134a361f8d778/', // 对应自己的接口
- changeOrigin: true,
- ws: false,
- pathRewrite: {
- '^/api': ''
- }
- }
- },
- overlay: {
- // 错误信息显示到浏览器上
- warnings: false,
- errors: true
- }
- },
- css: {
- // 开启样式追溯
- sourceMap: true
- },
- productionSourceMap: false,
- chainWebpack(config) {
- config.resolve.alias.set('@', resolve('src'))
- // set svg-sprite-loader
- config.module
- .rule('svg')
- .exclude.add(resolve('src/icons'))
- .end()
- config.module
- .rule('icons')
- .test(/\.svg$/)
- .include.add(resolve('src/icons'))
- .end()
- .use('svg-sprite-loader')
- .loader('svg-sprite-loader')
- .options({
- symbolId: 'icon-[name]'
- })
- .end()
- }
- }
|