vue.config.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. const CompressionWebpackPlugin = require('compression-webpack-plugin'); // 开启压缩
  2. const webpack = require('webpack');
  3. // const isProduction = process.env.NODE_ENV === 'production';
  4. module.exports = {
  5. publicPath: './',
  6. productionSourceMap: false,
  7. devServer: {
  8. port: 8081,
  9. },
  10. pages: {
  11. mobile: {
  12. entry: 'src/mobile.js',
  13. template: 'public/mobile.html',
  14. filename: 'mobile.html'
  15. },
  16. index: {
  17. entry: 'src/main.js',
  18. template: 'public/index.html',
  19. filename: 'index.html'
  20. },
  21. },
  22. chainWebpack: config => {
  23. config.plugins.delete('prefetch')
  24. },
  25. css: {
  26. extract: {
  27. Type: true,
  28. },
  29. loaderOptions: {
  30. css: {},
  31. postcss: {
  32. plugins: [
  33. require('postcss-plugin-px2rem')({
  34. rootValue: 75,
  35. exclude: /(node_module)/,
  36. }),
  37. ]
  38. }
  39. }
  40. },
  41. configureWebpack: {
  42. // 服务器也要相应开启gzip
  43. plugins: [
  44. // new CompressionWebpackPlugin({
  45. // algorithm: 'gzip',
  46. // test: /\.(js|css|png)$/, // 匹配文件名
  47. // threshold: 0, // 对超过10k的数据压缩
  48. // deleteOriginalAssets: true, // 不删除源文件
  49. // minRatio: 0.8 // 压缩比
  50. // }),
  51. new webpack.optimize.LimitChunkCountPlugin({
  52. maxChunks:20,
  53. minChunkSize: 1000
  54. })
  55. ]
  56. }
  57. }