vue.config.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. const path = require('path')
  2. const LiveReloadPlugin = require('webpack-livereload-plugin')
  3. function pathResolve() {
  4. return path.resolve(__dirname, ...arguments)
  5. }
  6. const inDev = process.env.NODE_ENV === 'development'
  7. const adminFolder = `admin${inDev ? '-dev' : ''}`
  8. module.exports = {
  9. outputDir: pathResolve('public/', adminFolder),
  10. publicPath: '/' + adminFolder,
  11. lintOnSave: false,
  12. configureWebpack: {
  13. entry: pathResolve('resources/src/main.js'),
  14. externals: {
  15. "BMap": "BMap"
  16. },
  17. plugins: [
  18. new LiveReloadPlugin(),
  19. ],
  20. watchOptions: {
  21. poll: (process.argv.indexOf('--poll') !== -1) ? 500 : false,
  22. aggregateTimeout: 500,
  23. ignored: /node_modules/,
  24. },
  25. },
  26. chainWebpack(config) {
  27. config
  28. .plugin('html')
  29. .tap((args) => {
  30. const o = args[0]
  31. o.template = pathResolve('resources/src/template/index.html')
  32. o.filename = pathResolve(`public/${adminFolder}/index.html`)
  33. return args
  34. })
  35. config.plugins.delete('copy')
  36. config
  37. .resolve
  38. .alias
  39. .set('@', pathResolve('resources/src'))
  40. .set('@c', pathResolve('resources/src/components'))
  41. .set('@v', pathResolve('resources/src/views'))
  42. // set svg-sprite-loader
  43. config.module
  44. .rule('svg')
  45. .exclude.add(pathResolve('resources/src/icons'))
  46. .end()
  47. config.module
  48. .rule('icons')
  49. .test(/\.svg$/)
  50. .include.add(pathResolve('resources/src/icons'))
  51. .end()
  52. .use('svg-sprite-loader')
  53. .loader('svg-sprite-loader')
  54. .options({
  55. symbolId: 'icon-[name]',
  56. })
  57. .end()
  58. },
  59. }