123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- 'use strict'
- const webpack = require('webpack');
- const path = require('path')
- const resolve = dir => path.resolve(__dirname, dir)
- const CompressionWebpackPlugin = require('compression-webpack-plugin');
- const productionGzipExtensions = /\.(js|css|json|txt|html|ico|svg)(\?.*)?$/i;
- const IS_PROD = ['production', 'prod'].includes(process.env.NODE_ENV);
- const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
- module.exports = {
- transpileDependencies: ['webpack-dev-server/client'],
-
- publicPath: '/',
-
- outputDir: 'dist',
-
- lintOnSave: false,
- assetsDir: '',
-
- runtimeCompiler: true,
-
- productionSourceMap: false,
- chainWebpack: config => {
- config
- .entry('./src/main.js')
- .add('babel-polyfill');
- config.resolve.symlinks(true);
-
- config.resolve.alias
- .set('@', resolve('src'))
-
-
-
- config.plugin('html').tap(args => {
-
- args[0].chunksSortMode = 'none';
- return args;
- })
-
-
-
-
-
-
-
-
-
-
- if (IS_PROD) {
- config.plugin("webpack-report").use(BundleAnalyzerPlugin, [{
- analyzerMode: "static"
- }]);
- }
- },
- css: {
-
- sourceMap: false,
- modules: false,
- loaderOptions: {
- less: {
- javascriptEnabled: true,
- }
- }
- },
-
- pluginOptions: {
- 'style-resources-loader': {
- preProcessor: 'less',
- patterns: ['src/assets/common/css/theme.less']
- }
- },
- devServer: {
- port: "8082",
- open: true,
- hot: true,
- proxy: {
- '/simulation/oauth': {
- target: 'http://10.12.10.70',
- changeOrigin: true,
- secure: false,
- pathRewrite: {
- '^/simulation/oauth': '/simulation/oauth'
- }
- },
- '/simulation/resource/common': {
-
-
-
-
- target: 'http://10.12.10.70',
-
-
-
-
-
- changeOrigin: true,
- secure: false,
- pathRewrite: {
- '^/simulation/resource/common': '/simulation/resource/common'
- }
- },
- '/simulation/resource/server': {
-
-
-
-
- target: 'http://10.12.10.70',
-
-
-
- changeOrigin: true,
- secure: false,
- pathRewrite: {
- '^/simulation/resource/server': '/simulation/resource/server'
- }
- },
- }
- },
- configureWebpack: config => {
- const plugins = [];
- plugins.push(
- new webpack.ProvidePlugin({
- $: "jquery",
- jQuery: "jquery",
- "windows.jQuery": "jquery",
- 'window.Quill': 'quill/dist/quill.js',
- 'Quill': 'quill/dist/quill.js'
- })
- )
- if (IS_PROD) {
-
- plugins.push(
- new CompressionWebpackPlugin({
- filename: '[path].gz[query]',
- algorithm: 'gzip',
- test: productionGzipExtensions,
- threshold: 10240,
- minRatio: 0.8
- })
- );
- }
- config.plugins = [
- ...config.plugins,
- ...plugins
- ];
- },
- }
|