vue.config.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. const path = require('path')
  2. const minify = process.env.NODE_ENV === 'development' ? false : {
  3. collapseWhitespace: true,
  4. removeComments: true,
  5. removeRedundantAttributes: true,
  6. removeScriptTypeAttributes: true,
  7. removeStyleLinkTypeAttributes: true,
  8. useShortDoctype: true,
  9. minifyCSS: true,
  10. minifyJS: true
  11. }
  12. function resolve(dir) {
  13. return path.join(__dirname, dir)
  14. }
  15. module.exports = {
  16. publicPath: '/',
  17. runtimeCompiler: true,
  18. pages: {
  19. index: {
  20. entry: 'src/main.js',
  21. template: 'public/index.html',
  22. filename: 'index.html',
  23. chunks: ['chunk-vendors', 'chunk-common', 'index'],
  24. minify
  25. },
  26. preview: {
  27. entry: 'src/views/preview/main.js',
  28. template: 'public/preview.html',
  29. filename: 'preview.html',
  30. chunks: ['chunk-vendors', 'chunk-common', 'preview'],
  31. minify
  32. }
  33. },
  34. devServer: {
  35. overlay: false
  36. },
  37. productionSourceMap: false,
  38. configureWebpack: {
  39. externals: {
  40. // vue: 'Vue',
  41. // 'vue-router': 'VueRouter',
  42. // 'element-ui': 'ELEMENT'
  43. }
  44. },
  45. chainWebpack(config) {
  46. config.resolve.alias.set('@', resolve('src'))
  47. // set svg-sprite-loader
  48. config.module
  49. .rule('svg')
  50. .exclude.add(resolve('src/icons'))
  51. .end()
  52. config.module
  53. .rule('icons')
  54. .test(/\.svg$/)
  55. .include.add(resolve('src/icons'))
  56. .end()
  57. .use('svg-sprite-loader')
  58. .loader('svg-sprite-loader')
  59. .options({
  60. symbolId: 'icon-[name]'
  61. })
  62. .end()
  63. }
  64. }