1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- 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: {
- 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()
- }
- }
|