邃芒官网、邃芒慧影、口播(H5) https://m.metavatar.cc
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

122 строки
3.2 KiB

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