pages.js 6.9 KB

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