1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- 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('@views', resolve('src/views'))
- .set('@router', resolve('src/router'))
- .set('@store', resolve('src/store'))
- .set('@layout',resolve('src/layout'))
- .set('@utils',resolve('src/utils'))
- .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,
- },
-
- }
|