pages.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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. config.performance = {
  60. hints: 'warning',
  61. //入口起点的最大体积 整数类型(以字节为单位)
  62. maxEntrypointSize: 50000000,
  63. //生成文件的最大体积 整数类型(以字节为单位 300k)
  64. maxAssetSize: 30000000,
  65. //只给出 js 文件的性能提示
  66. assetFilter: function(assetFilename) {
  67. return assetFilename.endsWith('.js');
  68. }
  69. }
  70. },
  71. },
  72. //住宅小区
  73. residence: {
  74. pages: {
  75. index: {
  76. entry: 'src/projects/residence/main.js',
  77. template: 'index/residence/index.html',
  78. filename: 'index.html',
  79. title: '小鹏管家' + title,
  80. }
  81. },
  82. outputDir: 'dist/residence',
  83. devServer: {
  84. host: '0.0.0.0',
  85. port: 8080,
  86. //解析缓存
  87. disableHostCheck: true,
  88. //支持gzip
  89. compress: true,
  90. },
  91. chainWebpack: (config) => {
  92. config.entry.app = ['babel-polyfill', '../src/projects/residence/main.js']
  93. config.resolve.alias
  94. .set('@', resolve('../src/projects/residence/'))
  95. .set('$project', resolve('../src/'))
  96. config.plugins.delete('preload');
  97. config.plugins.delete('prefetch');
  98. config.optimization.minimize(true);
  99. },
  100. configureWebpack: (config) => {
  101. //开启gzip压缩,需要配置Nginx服务器gzip选项开启
  102. /* config.plugins.push(
  103. new CompressionWebpackPlugin({
  104. filename: '[path].gz[query]',
  105. algorithm: 'gzip',
  106. test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
  107. threshold: 10240,
  108. minRatio: 0.8
  109. })
  110. ); */
  111. config.output.filename = `./static/js/[name].${Timestamp}.js`
  112. config.output.chunkFilename = `./static/js/[name].${Timestamp}.js`
  113. config.performance = {
  114. hints: 'warning',
  115. //入口起点的最大体积 整数类型(以字节为单位)
  116. maxEntrypointSize: 50000000,
  117. //生成文件的最大体积 整数类型(以字节为单位 300k)
  118. maxAssetSize: 30000000,
  119. //只给出 js 文件的性能提示
  120. assetFilter: function(assetFilename) {
  121. return assetFilename.endsWith('.js');
  122. }
  123. }
  124. },
  125. },
  126. //机构/居家养老
  127. pension: {
  128. pages: {
  129. index: {
  130. entry: 'src/projects/pension/main.js',
  131. template: 'index/pension/index.html',
  132. filename: 'index.html',
  133. title: '小鹏管家' + title,
  134. }
  135. },
  136. outputDir: 'dist/pension',
  137. devServer: {
  138. host: '0.0.0.0',
  139. port: 8080,
  140. //解析缓存
  141. disableHostCheck: true,
  142. //支持gzip
  143. compress: true,
  144. },
  145. chainWebpack: (config) => {
  146. config.entry.app = ['babel-polyfill', '../src/projects/pension/main.js']
  147. config.resolve.alias
  148. .set('@', resolve('../src/projects/pension/'))
  149. .set('$project', resolve('../src/'))
  150. config.plugins.delete('preload');
  151. config.plugins.delete('prefetch');
  152. config.optimization.minimize(true);
  153. },
  154. configureWebpack: (config) => {
  155. /* //开启gzip压缩,需要配置Nginx服务器gzip选项开启
  156. config.plugins.push(
  157. new CompressionWebpackPlugin({
  158. filename: '[path].gz[query]',
  159. algorithm: 'gzip',
  160. test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
  161. threshold: 10240,
  162. minRatio: 0.8
  163. })
  164. ); */
  165. config.output.filename = `./static/js/[name].${Timestamp}.js`
  166. config.output.chunkFilename = `./static/js/[name].${Timestamp}.js`
  167. config.performance = {
  168. hints: 'warning',
  169. //入口起点的最大体积 整数类型(以字节为单位)
  170. maxEntrypointSize: 50000000,
  171. //生成文件的最大体积 整数类型(以字节为单位 300k)
  172. maxAssetSize: 30000000,
  173. //只给出 js 文件的性能提示
  174. assetFilter: function(assetFilename) {
  175. return assetFilename.endsWith('.js');
  176. }
  177. }
  178. },
  179. },
  180. //入口
  181. home: {
  182. pages: {
  183. index: {
  184. entry: 'src/projects/home/main.js',
  185. template: 'index/home/index.html',
  186. filename: 'index.html',
  187. title: '小鹏管家' + title,
  188. }
  189. },
  190. outputDir: 'dist/home',
  191. devServer: {
  192. host: '0.0.0.0',
  193. port: 8080,
  194. //解析缓存
  195. disableHostCheck: true,
  196. //支持gzip
  197. compress: true,
  198. },
  199. chainWebpack: (config) => {
  200. config.entry.app = ['babel-polyfill', '../src/projects/home/main.js']
  201. config.resolve.alias
  202. .set('@', resolve('../src/projects/home/'))
  203. .set('$project', resolve('../src/'))
  204. config.plugins.delete('preload');
  205. config.plugins.delete('prefetch');
  206. config.optimization.minimize(true);
  207. },
  208. configureWebpack: (config) => {
  209. /* //开启gzip压缩,需要配置Nginx服务器gzip选项开启
  210. config.plugins.push(
  211. new CompressionWebpackPlugin({
  212. filename: '[path].gz[query]',
  213. algorithm: 'gzip',
  214. test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
  215. threshold: 10240,
  216. minRatio: 0.8
  217. })
  218. ); */
  219. config.output.filename = `./static/js/[name].${Timestamp}.js`
  220. config.output.chunkFilename = `./static/js/[name].${Timestamp}.js`
  221. config.performance = {
  222. hints: 'warning',
  223. //入口起点的最大体积 整数类型(以字节为单位)
  224. maxEntrypointSize: 50000000,
  225. //生成文件的最大体积 整数类型(以字节为单位 300k)
  226. maxAssetSize: 30000000,
  227. //只给出 js 文件的性能提示
  228. assetFilter: function(assetFilename) {
  229. return assetFilename.endsWith('.js');
  230. }
  231. }
  232. },
  233. }
  234. }
  235. const configObj = config[projectName.name]
  236. module.exports = configObj