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

140 рядки
3.6 KiB

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