123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
- 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,
-
-
-
-
-
-
-
-
-
-
-
-
-
- devServer: {
- hot: true,
- port: devPort,
- open: true,
- noInfo: false,
- overlay: {
- warnings: true,
- errors: true,
- },
- proxy: {
- '/borui/duoduo-service/': {
- target: 'https://duoduoenv.sagacloud.cn',
- changeOrigin: true,
- pathRewrite: {
- '^/borui/duoduo-service': '/duoduo-service'
- }
- },
- '/sgh5/sso/': {
- target: 'http://10.100.28.79/sgadmin/environment',
- changeOrigin: true,
- pathRewrite: {
- '^/sgh5/sso': '/sgh5/sso'
- }
- },
- '/sgh5/duoduo-service/': {
- target: 'http://10.100.28.79',
-
- changeOrigin: true,
- pathRewrite: {
- '^/sgh5/duoduo-service': '/sgh5/duoduo-service'
- }
- },
- '/sgh5/test': {
- target: 'http://192.168.0.65:52016',
- changeOrigin: true,
- pathRewrite: {
- '^/sgh5/test': ''
- }
- },
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- },
- 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 CompressionPlugin({
-
- threshold: 1024 * 10,
- minRatio: 0.8,
- algorithm: 'gzip',
- test: /\.js$|\.css$/,
- filename: '[path].gz[query]',
- deleteOriginalAssets: false
- }),
- new WebpackBar({
- name: title
- })
- ] : [new WebpackBar({
- name: title
- })],
-
-
-
-
-
-
-
- }
- },
- chainWebpack: config => {
- 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
- })
- }
- }
|