vue.config.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. const path = require('path')
  2. const webpack = require('webpack')
  3. // const GenerateAssetPlugin = require('generate-asset-webpack-plugin')
  4. function resolve(dir) {
  5. return path.join(__dirname, dir)
  6. }
  7. // var createServerConfig = function(compilation) {
  8. // const configJson = {
  9. // apiUrl: 'http://localhost:8090'
  10. // }
  11. // return JSON.stringify(configJson)
  12. // }
  13. // vue.config.js
  14. module.exports = {
  15. publicPath: '/',
  16. outputDir: 'dist',
  17. assetsDir: 'static_vue',
  18. configureWebpack: {
  19. plugins: [
  20. new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)
  21. // new GenerateAssetPlugin({
  22. // filename: 'config.json',
  23. // fn: (compilation, cb) => {
  24. // cb(null, createServerConfig(compilation))
  25. // },
  26. // extraFiles: []
  27. // })
  28. ]
  29. },
  30. chainWebpack: (config) => {
  31. config.resolve.alias
  32. .set('@$', resolve('src'))
  33. .set('@api', resolve('src/api'))
  34. .set('@assets', resolve('src/assets'))
  35. .set('@comp', resolve('src/components'))
  36. .set('@views', resolve('src/views'))
  37. .set('@layout', resolve('src/layout'))
  38. .set('@static', resolve('src/static'))
  39. const svgRule = config.module.rule('svg')
  40. svgRule.uses.clear()
  41. svgRule
  42. .oneOf('inline')
  43. .resourceQuery(/inline/)
  44. .use('vue-svg-icon-loader')
  45. .loader('vue-svg-icon-loader')
  46. .end()
  47. .end()
  48. .oneOf('external')
  49. .use('file-loader')
  50. .loader('file-loader')
  51. .options({
  52. name: 'assets/[name].[hash:8].[ext]'
  53. })
  54. },
  55. css: {
  56. loaderOptions: {
  57. less: {
  58. modifyVars: {
  59. /*
  60. 'primary-color': '#F5222D',
  61. 'link-color': '#F5222D',
  62. 'border-radius-base': '4px',
  63. */
  64. },
  65. javascriptEnabled: true
  66. }
  67. }
  68. },
  69. lintOnSave: undefined,
  70. // babel-loader no-ignore node_modules/*
  71. transpileDependencies: [],
  72. productionSourceMap: false
  73. }