123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- const path = require('path');
- const IS_PROD = ['production', 'prod'].includes(process.env.NODE_ENV);
- const resolve = (dir) => path.join(__dirname, dir);
- const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
- module.exports = {
- publicPath: "./",
- indexPath: 'index.html',
- outputDir: 'dist',
- assetsDir: 'static',
- lintOnSave: false,
- runtimeCompiler: true,
- productionSourceMap: !IS_PROD,
- chainWebpack: config => {
- config.resolve.symlinks(true);
-
- config.resolve.alias
- .set('@', resolve('src'))
- .set('@api', resolve('src/api'))
- .set('@tools', resolve('src/tools'))
- .set('@assets', resolve('src/assets'))
- .set('@components', resolve('src/components'))
- .set('@pages', resolve('src/pages'))
- .set('@router', resolve('src/router'))
- .set('@store', resolve('src/store'))
- .set('@jsonData', resolve('src/jsonData'));
-
- if (IS_PROD) {
- config.module
- .rule("images")
- .use("image-webpack-loader")
- .loader("image-webpack-loader")
- .options({
- mozjpeg: { progressive: true, quality: 65 },
- optipng: { enabled: false },
- pngquant: { quality: [0.65, 0.9], speed: 4 },
- gifsicle: { interlaced: false }
-
- });
- }
- },
- css: {
- loaderOptions: {
- sass: {
- prependData: `@import "./src/assets/css/default";`,
- },
- },
- },
-
- configureWebpack: config => {
- if (IS_PROD) {
- const plugins = [];
- plugins.push(
- new UglifyJsPlugin({
- uglifyOptions: {
- compress: {
- drop_console: true,
- drop_debugger: false,
- pure_funcs: ["console.log"]
- }
- },
- sourceMap: false,
- parallel: true
- })
- );
- config.plugins = [...config.plugins, ...plugins];
- }
- },
- devServer: {
-
- proxy: {
-
- '/apizzz': {
- target: 'www.baidu.com',
- changeOrigin: true,
- pathRewrite: {
-
- }
- }
- },
- open: true,
- }
- }
|