vue.config.js 2.2 KB

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