123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- 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: 8080,
- //解析缓存
- 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/'))
- config.plugins.delete('preload');
- config.plugins.delete('prefetch');
- config.optimization.minimize(true);
- },
- configureWebpack: config => {
- /* //开启gzip压缩,需要配置Nginx服务器gzip选项开启
- config.plugins.push(
- new CompressionWebpackPlugin({
- filename: '[path].gz[query]',
- algorithm: 'gzip',
- test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
- threshold: 10240,
- minRatio: 0.8
- })
- ); */
- config.output.filename = `./static/js/[name].${Timestamp}.js`
- config.output.chunkFilename = `./static/js/[name].${Timestamp}.js`
- },
- },
- //工厂
- factory: {
- pages: {
- index: {
- entry: 'src/projects/factory/main.js',
- template: 'index/factory/index.html',
- filename: 'index.html',
- title: '' + title,
- }
- },
- outputDir: 'dist/factory',
- devServer: {
- host: '0.0.0.0',
- port: 8080,
- //解析缓存
- disableHostCheck: true,
- //支持gzip
- compress: true,
- },
- chainWebpack: (config) => {
- config.entry.app = ['babel-polyfill', '../src/projects/factory/main.js']
- config.resolve.alias
- .set('@', resolve('../src/projects/factory/'))
- .set('$project', resolve('../src/'))
- config.plugins.delete('preload');
- config.plugins.delete('prefetch');
- config.optimization.minimize(true);
- },
- /* configureWebpack: (config) => {
- //开启gzip压缩,需要配置Nginx服务器gzip选项开启
- config.plugins.push(
- new CompressionWebpackPlugin({
- filename: '[path].gz[query]',
- algorithm: 'gzip',
- test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
- threshold: 10240,
- minRatio: 0.8
- })
- );
- }, */
- },
- //养老院
- 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/'))
- config.plugins.delete('preload');
- config.plugins.delete('prefetch');
- config.optimization.minimize(true);
- },
- /* configureWebpack: (config) => {
- //开启gzip压缩,需要配置Nginx服务器gzip选项开启
- config.plugins.push(
- new CompressionWebpackPlugin({
- filename: '[path].gz[query]',
- algorithm: 'gzip',
- test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
- threshold: 10240,
- minRatio: 0.8
- })
- );
- }, */
- }
- }
- const configObj = config[projectName.name]
- module.exports = configObj
|