vue.config.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. devServer: {
  70. disableHostCheck: false,
  71. host: "120.26.90.3",
  72. port: 9080,
  73. https: false,
  74. hotOnly: false,
  75. proxy: null
  76. },
  77. lintOnSave: undefined,
  78. // babel-loader no-ignore node_modules/*
  79. transpileDependencies: [],
  80. productionSourceMap: false
  81. }