邃芒官网、邃芒慧影、口播(H5) https://m.metavatar.cc
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

116 lines
2.9 KiB

  1. // const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
  2. const path = require('path');
  3. let externals = {}
  4. let cdn = { css: [], js: [] }
  5. const isProduction = process.env.VUE_APP_ENV == 'production' // 判断是否是生产环境
  6. if (isProduction) {
  7. externals = {
  8. /**
  9. * externals 对象属性解析:
  10. * '包名' : '在项目中引入的名字'
  11. */
  12. 'vue': 'Vue',
  13. 'element-ui': 'ELEMENT',
  14. 'xlsx': 'XLSX'
  15. }
  16. cdn = {
  17. css: [
  18. 'https://unpkg.com/element-ui/lib/theme-chalk/index.css' // element-ui css 样式表
  19. ],
  20. js: [
  21. // vue must at first!
  22. 'https://unpkg.com/vue@2.6.12/dist/vue.js', // vuejs
  23. 'https://unpkg.com/element-ui/lib/index.js', // element-ui js
  24. 'https://cdn.jsdelivr.net/npm/xlsx@0.16.6/dist/xlsx.full.min.js' // xlsx
  25. ]
  26. }
  27. }
  28. module.exports = {
  29. configureWebpack: {
  30. resolve: {
  31. alias: {
  32. '@': path.resolve(__dirname, 'src')
  33. }
  34. },
  35. externals,
  36. },
  37. css: {
  38. loaderOptions: {
  39. css: {
  40. // options here will be passed to css-loader
  41. },
  42. // postcss: {
  43. // // options here will be passed to postcss-loader
  44. // plugins: [require('postcss-px2rem')({
  45. // remUnit: 75
  46. // })]
  47. // }
  48. }
  49. },
  50. pwa: {
  51. iconPaths: {
  52. favicon32: 'favicon.ico',
  53. favicon16: 'favicon.ico',
  54. appleTouchIcon: 'favicon.ico',
  55. maskIcon: 'favicon.ico',
  56. msTileImage: 'favicon.ico'
  57. }
  58. },
  59. //http://www.metavatar.cc/
  60. devServer: {
  61. overlay: {
  62. warnings: false,
  63. errors: false
  64. },
  65. proxy: {
  66. '/api': {
  67. // target: 'https://smapitestmalls,iformall.com/C/api',
  68. target: process.env.VUE_APP_API_ROOT+'/api',
  69. changeOrigin: true,
  70. pathRewrite: {
  71. '^/api': ''
  72. },
  73. },
  74. }
  75. },
  76. lintOnSave: false,
  77. publicPath: './', // 打包后引用的资源路径
  78. chainWebpack: config => {
  79. config.plugin('html').tap(args => {
  80. args[0].favicon = './public/favicon.ico';
  81. return args;
  82. });
  83. // 注入cdn变量 (打包时会执行)
  84. config.plugin('html').tap(args => {
  85. args[0].cdn = cdn // 配置cdn给插件
  86. return args
  87. })
  88. }
  89. // configureWebpack: {
  90. // plugins: [
  91. // //打包环境去掉console.log
  92. // new UglifyJsPlugin({
  93. // uglifyOptions: {
  94. // compress: {
  95. // drop_console: true, //注释console
  96. // drop_debugger: true, //注释debugger
  97. // pure_funcs: ['console.log'], //移除console.log
  98. // },
  99. // },
  100. // }),
  101. // ],
  102. // }
  103. }