pages.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. const projectName = require('./project');
  2. const path = require('path');
  3. const CompressionWebpackPlugin = require("compression-webpack-plugin")
  4. const productionGzipExtensions = ['js', 'css']
  5. function resolve(dir) {
  6. return path.join(__dirname, dir)
  7. }
  8. let title = '';
  9. if (process.env.VUE_APP_NODE_NAME == 'production') {
  10. title = ''
  11. } else if (process.env.VUE_APP_NODE_NAME == 'test') {
  12. title = '(测试)'
  13. } else {
  14. title = '(开发)'
  15. }
  16. const Timestamp = new Date().getTime();
  17. const config = {
  18. //商业园区
  19. business: {
  20. pages: {
  21. index: {
  22. entry: 'src/projects/business/main.js',
  23. template: 'index/business/index.html',
  24. filename: 'index.html',
  25. title: '' + title,
  26. }
  27. },
  28. outputDir: 'dist/business',
  29. devServer: {
  30. host: '0.0.0.0',
  31. port: 8080,
  32. //解析缓存
  33. disableHostCheck: true,
  34. //支持gzip
  35. compress: true,
  36. },
  37. chainWebpack: (config) => {
  38. config.entry.app = ['babel-polyfill', '../src/projects/business/main.js']
  39. config.resolve.alias
  40. .set('@', resolve('../src/projects/business/'))
  41. .set('$project', resolve('../src/'))
  42. config.plugins.delete('preload');
  43. config.plugins.delete('prefetch');
  44. config.optimization.minimize(true);
  45. },
  46. configureWebpack: config => {
  47. /* //开启gzip压缩,需要配置Nginx服务器gzip选项开启
  48. config.plugins.push(
  49. new CompressionWebpackPlugin({
  50. filename: '[path].gz[query]',
  51. algorithm: 'gzip',
  52. test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
  53. threshold: 10240,
  54. minRatio: 0.8
  55. })
  56. ); */
  57. config.output.filename = `./static/js/[name].${Timestamp}.js`
  58. config.output.chunkFilename = `./static/js/[name].${Timestamp}.js`
  59. },
  60. },
  61. //工厂
  62. factory: {
  63. pages: {
  64. index: {
  65. entry: 'src/projects/factory/main.js',
  66. template: 'index/factory/index.html',
  67. filename: 'index.html',
  68. title: '' + title,
  69. }
  70. },
  71. outputDir: 'dist/factory',
  72. devServer: {
  73. host: '0.0.0.0',
  74. port: 8080,
  75. //解析缓存
  76. disableHostCheck: true,
  77. //支持gzip
  78. compress: true,
  79. },
  80. chainWebpack: (config) => {
  81. config.entry.app = ['babel-polyfill', '../src/projects/factory/main.js']
  82. config.resolve.alias
  83. .set('@', resolve('../src/projects/factory/'))
  84. .set('$project', resolve('../src/'))
  85. config.plugins.delete('preload');
  86. config.plugins.delete('prefetch');
  87. config.optimization.minimize(true);
  88. },
  89. /* configureWebpack: (config) => {
  90. //开启gzip压缩,需要配置Nginx服务器gzip选项开启
  91. config.plugins.push(
  92. new CompressionWebpackPlugin({
  93. filename: '[path].gz[query]',
  94. algorithm: 'gzip',
  95. test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
  96. threshold: 10240,
  97. minRatio: 0.8
  98. })
  99. );
  100. }, */
  101. },
  102. //养老院
  103. pension: {
  104. pages: {
  105. index: {
  106. entry: 'src/projects/pension/main.js',
  107. template: 'index/pension/index.html',
  108. filename: 'index.html',
  109. title: '' + title,
  110. }
  111. },
  112. outputDir: 'dist/pension',
  113. devServer: {
  114. host: '0.0.0.0',
  115. port: 8080,
  116. //解析缓存
  117. disableHostCheck: true,
  118. //支持gzip
  119. compress: true,
  120. },
  121. chainWebpack: (config) => {
  122. config.entry.app = ['babel-polyfill', '../src/projects/pension/main.js']
  123. config.resolve.alias
  124. .set('@', resolve('../src/projects/pension/'))
  125. .set('$project', resolve('../src/'))
  126. config.plugins.delete('preload');
  127. config.plugins.delete('prefetch');
  128. config.optimization.minimize(true);
  129. },
  130. /* configureWebpack: (config) => {
  131. //开启gzip压缩,需要配置Nginx服务器gzip选项开启
  132. config.plugins.push(
  133. new CompressionWebpackPlugin({
  134. filename: '[path].gz[query]',
  135. algorithm: 'gzip',
  136. test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
  137. threshold: 10240,
  138. minRatio: 0.8
  139. })
  140. );
  141. }, */
  142. }
  143. }
  144. const configObj = config[projectName.name]
  145. module.exports = configObj