123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 |
- const { resolve } = require("path");
- const path = require("path");
- const WebpackBar = require("webpackbar");
- const merge = require("webpack-merge");
- const tsImportPluginFactory = require("ts-import-plugin");
- const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
- const productionGzipExtensions = ["js", "css", "svg"];
- const isProduction = process.env.NODE_ENV === "production";
- const cdn = {
- css: ["https://cdn.jsdelivr.net/npm/vant@3/lib/index.css"],
- js: [
- "https://unpkg.com/vue@3.2.31/dist/vue.global.js",
- "https://unpkg.com/vue-router@4.0.14/dist/vue-router.global.js",
- "https://unpkg.com/vuex@4.0.2/dist/vuex.global.js",
- "https://cdn.jsdelivr.net/npm/vant@3/lib/vant.min.js",
- "https://cdn.jsdelivr.net/npm/echarts@5.3.2/dist/echarts.min.js"
- ]
- };
- const {
- publicPath,
- assetsDir,
- parallel,
- outputDir,
- lintOnSave,
- transpileDependencies,
- title,
- devPort
- } = require("./src/config/default/vue.custom.config");
- const CompressionPlugin = require("compression-webpack-plugin");
- module.exports = {
- publicPath,
- assetsDir,
- parallel,
- outputDir,
- lintOnSave,
- transpileDependencies,
-
-
-
-
-
-
-
-
-
-
-
-
-
- css: {
- loaderOptions: {
- postcss: {
- plugins: [
- require("postcss-pxtorem")({
-
- rootValue: 96,
- minPixelValue: 4,
- unitPrecision: 3,
- selectorBlackList: ["mu"],
- propList: ["*"]
- })
- ]
- }
- }
- },
- devServer: {
- hot: true,
- port: devPort,
- open: true,
- noInfo: false,
- overlay: {
- warnings: true,
- errors: true
- },
- proxy: {
- "/sgh5/duoduo-service/": {
- target: "https://duoduoenv.sagacloud.cn",
-
- changeOrigin: true,
- pathRewrite: {
- "^/sgh5/duoduo-service": "/duoduo-service"
- }
- },
- "/sgh5/pad_mtime": {
- target: "http://39.106.8.246:9091/",
- changeOrigin: true,
- pathRewrite: {
- "^/sgh5/pad_mtime": "/pad_mtime"
- }
- },
- "/sgh5/server/": {
-
- target: "http://sso.sagacloud.cn",
- changeOrigin: true,
- pathRewrite: {
- "^/sgh5/server": "/server"
- }
- },
- "/sgh5/mngserver/": {
-
- target: "http://mng.sagacloud.cn",
- changeOrigin: true,
- pathRewrite: {
- "^/sgh5/mngserver": "/server"
- }
- },
- "/sgh5/anon/": {
-
- target: "http://mng.sagacloud.cn",
- changeOrigin: true,
- pathRewrite: {
- "^/sgh5/anon": "/anon"
- }
- },
- "/sgh5/test/": {
-
- target: "http://192.168.88.6:52009",
-
-
- changeOrigin: true,
- pathRewrite: {
- "^/sgh5/test": ""
- }
- },
- "/sgh5/test1/": {
-
- target: "http://192.168.0.65:52009",
- changeOrigin: true,
- pathRewrite: {
- "^/sgh5/test1": ""
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- },
- pluginOptions: {
- "style-resources-loader": {
- preProcessor: "scss",
- patterns: [
- path.resolve(__dirname, "src/styles/_variables.scss"),
- path.resolve(__dirname, "src/styles/_mixins.scss")
- ]
- }
- },
- configureWebpack() {
- return {
- resolve: {
- alias: {
- "@": resolve("src"),
- "*": resolve(""),
- Assets: resolve("src/assets")
- }
- },
- module: {
- rules: [
- {
- test: /\.(json5?|ya?ml)$/,
- loader: "@intlify/vue-i18n-loader",
- include: [
-
- path.resolve(__dirname, "src/lang")
- ]
- }
- ]
- },
- plugins: isProduction
- ? [
- new UglifyJsPlugin({
- uglifyOptions: {
- compress: {
- drop_debugger: true,
- drop_console: true
- },
- warnings: false
- },
- sourceMap: false,
- parallel: true
- }),
-
- new CompressionPlugin({
- test: new RegExp(
- "\\.(" + productionGzipExtensions.join("|") + ")$"
- ),
- threshold: 1024 * 10,
- minRatio: 0.8,
- algorithm: "gzip",
-
- filename: "[path].gz[query]",
- deleteOriginalAssets: false
- }),
- new WebpackBar({
- name: title
- })
- ]
- : [
- new WebpackBar({
- name: title
- })
- ]
-
-
-
-
-
-
-
- };
- },
- chainWebpack: config => {
- config.plugins.delete("preload");
- config.plugins.delete("prefetch");
- config.optimization.minimizer("terser").tap(args => {
- args[0].parallel = 4;
- args[0].terserOptions.compress.warnings = true;
- args[0].terserOptions.compress.drop_debugger = true;
- args[0].terserOptions.compress.drop_console = true;
- return args;
- });
- config.module
- .rule("ts")
- .use("ts-loader")
- .tap(options => {
- options = merge(options, {
- transpileOnly: true,
- getCustomTransformers: () => ({
- before: [
- tsImportPluginFactory({
- libraryName: "vant",
- libraryDirectory: "es",
- style: true
- })
- ]
- }),
- compilerOptions: {
- module: "es2015"
- }
- });
- return options;
- });
- }
- };
|