123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336 |
- const projectName = require('./project');
- const path = require('path');
- const CompressionWebpackPlugin = require("compression-webpack-plugin")
- const productionGzipExtensions = ['js', 'css']
- function resolve(dir) {
- return path.join(__dirname, dir)
- }
- let title = '';
- if (process.env.VUE_APP_NODE_NAME == 'production') {
- title = ''
- } else if (process.env.VUE_APP_NODE_NAME == 'test') {
- title = '(测试)'
- } else {
- title = '(开发)'
- }
- const Timestamp = new Date().getTime();
- const config = {
- //商业园区
- business: {
- pages: {
- index: {
- entry: 'src/projects/business/main.js',
- template: 'index/business/index.html',
- filename: 'index.html',
- title: '小鹏管家' + title,
- }
- },
- outputDir: 'dist/business',
- devServer: {
- host: '0.0.0.0',
- port: 80,
- //解析缓存
- disableHostCheck: true,
- //支持gzip
- compress: true,
- },
- chainWebpack: (config) => {
- config.entry.app = ['babel-polyfill', '../src/projects/business/main.js']
- config.resolve.alias
- .set('@', resolve('../src/projects/business/'))
- .set('$project', resolve('../src/'))
- .set('$root', resolve('../'))
- config.plugins.delete('preload-index');
- config.plugins.delete('prefetch-index');
- config.optimization.minimize(true);
- //打包分析添加
- //config.output.filename('js/[name].[hash].js').end();
- //config.plugin('webpack-bundle-analyzer').use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin)
- },
- configureWebpack: config => {
- //开启gzip压缩,需要配置Nginx服务器gzip选项开启
- config.plugins.push(
- new CompressionWebpackPlugin({
- algorithm: 'gzip', //开启gzip
- test: /\.js$|\.html$|.\css/, // 匹配文件名
- threshold: 10240, // 对超过10k的数据压缩
- deleteOriginalAssets: false // 不删除源文件
- })
- );
- config.output.filename = `./static/js/[name].${Timestamp}.js`
- config.output.chunkFilename = `./static/js/[name].${Timestamp}.js`
- config.performance = {
- hints: 'warning',
- //入口起点的最大体积 整数类型(以字节为单位)
- maxEntrypointSize: 50000000,
- //生成文件的最大体积 整数类型(以字节为单位 300k)
- maxAssetSize: 30000000,
- //只给出 js 文件的性能提示
- assetFilter: function(assetFilename) {
- return assetFilename.endsWith('.js');
- }
- }
- },
- },
- //住宅小区
- residence: {
- pages: {
- index: {
- entry: 'src/projects/residence/main.js',
- template: 'index/residence/index.html',
- filename: 'index.html',
- title: '小鹏管家' + title,
- }
- },
- outputDir: 'dist/residence',
- devServer: {
- host: '0.0.0.0',
- port: 8080,
- //解析缓存
- disableHostCheck: true,
- //支持gzip
- compress: true,
- },
- chainWebpack: (config) => {
- config.entry.app = ['babel-polyfill', '../src/projects/residence/main.js']
- config.resolve.alias
- .set('@', resolve('../src/projects/residence/'))
- .set('$project', resolve('../src/'))
- .set('$root', resolve('../'))
- config.plugins.delete('preload-index');
- config.plugins.delete('prefetch-index');
- config.optimization.minimize(true);
- //打包分析添加
- //config.output.filename('js/[name].[hash].js').end();
- //config.plugin('webpack-bundle-analyzer').use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin)
- },
- configureWebpack: (config) => {
- //开启gzip压缩,需要配置Nginx服务器gzip选项开启
- config.plugins.push(
- new CompressionWebpackPlugin({
- algorithm: 'gzip', //开启gzip
- test: /\.js$|\.html$|.\css/, // 匹配文件名
- threshold: 10240, // 对超过10k的数据压缩
- deleteOriginalAssets: false // 不删除源文件
- })
- );
- config.output.filename = `./static/js/[name].${Timestamp}.js`
- config.output.chunkFilename = `./static/js/[name].${Timestamp}.js`
- config.performance = {
- hints: 'warning',
- //入口起点的最大体积 整数类型(以字节为单位)
- maxEntrypointSize: 50000000,
- //生成文件的最大体积 整数类型(以字节为单位 300k)
- maxAssetSize: 30000000,
- //只给出 js 文件的性能提示
- assetFilter: function(assetFilename) {
- return assetFilename.endsWith('.js');
- }
- }
- },
- },
- //机构/居家养老
- pension: {
- pages: {
- index: {
- entry: 'src/projects/pension/main.js',
- template: 'index/pension/index.html',
- filename: 'index.html',
- title: '小鹏管家' + title,
- }
- },
- outputDir: 'dist/pension',
- devServer: {
- host: '0.0.0.0',
- port: 8080,
- //解析缓存
- disableHostCheck: true,
- //支持gzip
- compress: true,
- },
- chainWebpack: (config) => {
- config.entry.app = ['babel-polyfill', '../src/projects/pension/main.js']
- config.resolve.alias
- .set('@', resolve('../src/projects/pension/'))
- .set('$project', resolve('../src/'))
- .set('$root', resolve('../'))
- config.plugins.delete('preload-index');
- config.plugins.delete('prefetch-index');
- config.optimization.minimize(true);
- //打包分析添加
- //config.output.filename('js/[name].[hash].js').end();
- //config.plugin('webpack-bundle-analyzer').use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin)
- },
- configureWebpack: (config) => {
- //开启gzip压缩,需要配置Nginx服务器gzip选项开启
- config.plugins.push(
- new CompressionWebpackPlugin({
- algorithm: 'gzip', //开启gzip
- test: /\.js$|\.html$|.\css/, // 匹配文件名
- threshold: 10240, // 对超过10k的数据压缩
- deleteOriginalAssets: false // 不删除源文件
- })
- );
- config.output.filename = `./static/js/[name].${Timestamp}.js`
- config.output.chunkFilename = `./static/js/[name].${Timestamp}.js`
- config.performance = {
- hints: 'warning',
- //入口起点的最大体积 整数类型(以字节为单位)
- maxEntrypointSize: 50000000,
- //生成文件的最大体积 整数类型(以字节为单位 300k)
- maxAssetSize: 30000000,
- //只给出 js 文件的性能提示
- assetFilter: function(assetFilename) {
- return assetFilename.endsWith('.js');
- }
- }
- },
- },
- //入口
- home: {
- pages: {
- index: {
- entry: 'src/projects/home/main.js',
- template: 'index/home/index.html',
- filename: 'index.html',
- title: '小鹏管家' + title,
- }
- },
- outputDir: 'dist/home',
- devServer: {
- host: '0.0.0.0',
- port: 8080,
- //解析缓存
- disableHostCheck: true,
- //支持gzip
- compress: true,
- },
- chainWebpack: (config) => {
- config.entry.app = ['babel-polyfill', '../src/projects/home/main.js']
- config.resolve.alias
- .set('@', resolve('../src/projects/home/'))
- .set('$project', resolve('../src/'))
- .set('$root', resolve('../'))
- config.plugins.delete('preload-index');
- config.plugins.delete('prefetch-index');
- config.optimization.minimize(true);
- //打包分析添加
- //config.output.filename('js/[name].[hash].js').end();
- //config.plugin('webpack-bundle-analyzer').use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin)
- },
- configureWebpack: (config) => {
- //开启gzip压缩,需要配置Nginx服务器gzip选项开启
- config.plugins.push(
- new CompressionWebpackPlugin({
- algorithm: 'gzip', //开启gzip
- test: /\.js$|\.html$|.\css/, // 匹配文件名
- threshold: 10240, // 对超过10k的数据压缩
- deleteOriginalAssets: false // 不删除源文件
- })
- );
- config.output.filename = `./static/js/[name].${Timestamp}.js`
- config.output.chunkFilename = `./static/js/[name].${Timestamp}.js`
- config.performance = {
- hints: 'warning',
- //入口起点的最大体积 整数类型(以字节为单位)
- maxEntrypointSize: 50000000,
- //生成文件的最大体积 整数类型(以字节为单位 300k)
- maxAssetSize: 30000000,
- //只给出 js 文件的性能提示
- assetFilter: function(assetFilename) {
- return assetFilename.endsWith('.js');
- }
- }
- },
- },
- //停车收费
- parking: {
- pages: {
- index: {
- entry: 'src/projects/parking/main.js',
- template: 'index/parking/index.html',
- filename: 'index.html',
- title: '小鹏管家停车收费' + title,
- }
- },
- outputDir: 'dist/parking',
- devServer: {
- host: '0.0.0.0',
- port: 8080,
- //解析缓存
- disableHostCheck: true,
- //支持gzip
- compress: true,
- },
- chainWebpack: (config) => {
- config.entry.app = ['babel-polyfill', '../src/projects/parking/main.js']
- config.resolve.alias
- .set('@', resolve('../src/projects/parking/'))
- .set('$project', resolve('../src/'))
- .set('$root', resolve('../'))
- config.plugins.delete('preload-index');
- config.plugins.delete('prefetch-index');
- config.optimization.minimize(true);
- //打包分析添加
- //config.output.filename('js/[name].[hash].js').end();
- //config.plugin('webpack-bundle-analyzer').use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin)
- },
- configureWebpack: config => {
- //开启gzip压缩,需要配置Nginx服务器gzip选项开启
- config.plugins.push(
- new CompressionWebpackPlugin({
- algorithm: 'gzip', //开启gzip
- test: /\.js$|\.html$|.\css/, // 匹配文件名
- threshold: 10240, // 对超过10k的数据压缩
- deleteOriginalAssets: false // 不删除源文件
- })
- );
- config.output.filename = `./static/js/[name].${Timestamp}.js`
- config.output.chunkFilename = `./static/js/[name].${Timestamp}.js`
- config.performance = {
- hints: 'warning',
- //入口起点的最大体积 整数类型(以字节为单位)
- maxEntrypointSize: 50000000,
- //生成文件的最大体积 整数类型(以字节为单位 300k)
- maxAssetSize: 30000000,
- //只给出 js 文件的性能提示
- assetFilter: function(assetFilename) {
- return assetFilename.endsWith('.js');
- }
- }
- },
- }
- }
- const configObj = config[projectName.name]
- module.exports = configObj
|