123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248 |
- const path = require('path');
- const { defineConfig } = require('@vue/cli-service');
- const webpack = require('webpack');
- const SpeedMeasurePlugin = require('speed-measure-webpack-plugin');
- const dayjs = require('dayjs');
- const TerserPlugin = require('terser-webpack-plugin');
- const resolve = (dir) => path.join(__dirname, dir);
- const pkg = require('./package.json');
- process.env.VUE_APP_VERSION = pkg.version;
- const IS_PROD = ['production', 'prod'].includes(process.env.NODE_ENV);
- const IS_DEV = ['development'].includes(process.env.NODE_ENV);
- const port = process.env.port || process.env.npm_config_port || 8201;
- const __APP_INFO__ = {
- pkg,
- lastBuildTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
- };
- module.exports = defineConfig({
- lintOnSave: false,
-
-
- publicPath: '/web/',
-
- productionSourceMap: false,
- outputDir: "../src/main/resources/static/web",
- css: {
- loaderOptions: {
-
-
-
-
-
-
-
- less: {
- lessOptions: {
- javascriptEnabled: true,
- modifyVars: {},
- },
- additionalData: `
- @import "ant-design-vue/lib/style/themes/default.less";
- @import "~@/styles/variables.less";
- `,
- },
-
-
-
-
-
- },
- },
- chainWebpack: (config) => {
-
- config.plugins.delete('preload');
-
- config.plugins.delete('prefetch');
-
- config.cache({
-
- type: 'filesystem',
- buildDependencies: {
-
- config: [__filename],
- },
- });
-
- config.optimization.runtimeChunk('single');
- config
-
- .when(IS_DEV, (config) => config.devtool('cheap-source-map'));
-
- config.resolve.alias.set('@', resolve('src'));
- config.resolve.alias.set('vue-i18n', 'vue-i18n/dist/vue-i18n.cjs.js');
- if (process.env.DEBUG_ANTDV) {
- console.info('DEBUG_ANTDV', process.env.DEBUG_ANTDV);
- config.resolve.alias.set('ant-design-vue/es/', 'ant-design-vue/components/');
- config.resolve.alias.set('ant-design-vue/lib/', 'ant-design-vue/components/');
- config.resolve.alias.set('vue', 'ant-design-vue/node_modules/vue');
- }
- config.plugin('html').tap((args) => {
- args[0].title = '惠州市就业驿站管理系统';
- return args;
- });
- config.module
- .rule('css')
- .exclude.add(resolve('node_modules/ant-design-vue/dist/antd.dark.css'))
- .end();
- config.module.rule('raw-css').resourceQuery(/raw/).type('asset/source');
-
- config.module.noParse(/\.md$/);
-
-
- config.module.rule('svg').exclude.add(resolve('src/assets/icons')).end();
- config.module
- .rule('icons')
- .test(/\.svg$/)
- .include.add(resolve('src/assets/icons'))
- .end()
- .use('svg-sprite-loader')
- .loader('svg-sprite-loader')
- .options({
- symbolId: 'svg-icon-[name]',
- });
- config.when(IS_PROD, (config) => {
-
- config.optimization.splitChunks({
- chunks: 'all',
- cacheGroups: {
- libs: {
- name: 'chunk-libs',
- test: /[\\/]node_modules[\\/]/,
- priority: 10,
- chunks: 'initial',
- },
- antdv: {
- name: 'chunk-ant-design-vue',
- priority: 20,
- test: /[\\/]node_modules[\\/]_?ant-design-vue(.*)/,
- },
- commons: {
- name: 'chunk-commons',
- test: resolve('src/components'),
- minChunks: 3,
- priority: 5,
- reuseExistingChunk: true,
- },
- },
- });
- config.module
- .rule('md')
- .test(/\.md$/)
- .type('javascript/auto')
- .use('asset')
- .loader('asset')
- .options({
- limit: 100,
- esModule: false,
- generator: () => '',
- });
- });
- },
- configureWebpack: (config) => {
-
- config.experiments = {
- topLevelAwait: true,
- };
- config.resolve.fallback = { path: require.resolve('path-browserify') };
- config.devtool = 'source-map';
- config.plugins.push(
-
- new webpack.DefinePlugin({
- __APP_INFO__: JSON.stringify(__APP_INFO__),
- }),
-
- new SpeedMeasurePlugin(),
-
- require('unplugin-vue-define-options/webpack')(),
- );
- if (IS_PROD) {
-
- const TerserPluginIndex = config.optimization.minimizer.findIndex(
- (n) => n.__pluginName === 'terser',
- );
- config.optimization.minimizer[TerserPluginIndex] = new TerserPlugin({
- terserOptions: {
- warnings: false,
- format: {
- comments: false,
- },
- compress: {
- drop_debugger: true,
- drop_console: true,
- pure_funcs: ['console.log'],
- },
- },
- extractComments: false,
- parallel: true,
- });
- }
- },
- devServer: {
- port,
- client: {
- progress: true,
- },
-
-
-
-
-
- proxy: {
-
-
-
-
-
-
-
-
- '^/api': {
-
- target: 'http://localhost:8200',
-
- changeOrigin: true,
- logLevel: 'debug',
- pathRewrite: {
- '^/api': '/api',
- },
- },
- '^/n-api': {
-
- target: 'http://localhost:8200',
-
- changeOrigin: true,
- logLevel: 'debug',
- pathRewrite: {
- '^/n-api': '/api',
- },
- },
- '^/ws-api': {
- target: 'wss://nest-api.buqiyuan.site',
-
- changeOrigin: true,
- wss: true,
- logLevel: 'debug',
- },
- },
- setupMiddlewares: require('./src/mock/mock-server.js'),
- },
- });
|