1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- const { defineConfig } = require('@vue/cli-service')
- const path = require('path')
- const AutoImport = require('unplugin-auto-import/webpack')
- const Components = require('unplugin-vue-components/webpack')
- const { ElementPlusResolver, VantResolver } = require('unplugin-vue-components/resolvers')
- const ElementPlus = require('unplugin-element-plus/webpack')
- const CompressionPlugin = require('compression-webpack-plugin')
- function resolve (dir) {
- return path.join(__dirname, dir)
- }
- module.exports = defineConfig({
- transpileDependencies: true,
- devServer: {
- proxy: { // 配置跨域
- '/api': {
- // target: 'http://yhq.wenxingshuju.com', // 线上
- // target: 'http://192.168.0.184:9009', // 后端本地
- // target: 'http://39.106.149.78:9009', // 测试环境
- target: 'http://yhq-test.wenxingshuju.com', // 测试环境
- changeOrigin: true, // 允许跨域
- pathRewrite: {
- '^/api': '' // 请求的时候使用这个api就可以
- }
- }
- }
- },
- lintOnSave: false,
- publicPath: process.env.NODE_ENV === 'production' ? './' : '/',
- outputDir: 'dist',
- productionSourceMap: false,//打包不到.map文件
- configureWebpack: {
- // provide the app's title in webpack's name field, so that
- // it can be accessed in index.html to inject the correct title.
- resolve: {
- alias: {
- '@': resolve('src')
- },
- },
- plugins: [
- AutoImport({
- resolvers: [ElementPlusResolver()],
- }),
- Components({
- resolvers: [ElementPlusResolver(), VantResolver()],
- }),
- ElementPlus(),
- new CompressionPlugin({
- test: /\.js$|\.html$|\.css/, //匹配文件名
- threshold: 10240, //对超过10k的数据进行压缩
- deleteOriginalAssets: false //是否删除原文件
- }),
- ],
- },
- chainWebpack (config) {
- // set svg-sprite-loader
- config.module
- .rule('svg')
- .exclude.add(resolve('src/assets/svg')) // 存放 svg 目录的目录
- .end()
- config.module
- .rule('icons')
- .test(/\.svg$/)
- .include.add(resolve('src/assets/svg')) // 存放 svg 目录的目录
- .end()
- .use('svg-sprite-loader')
- .loader('svg-sprite-loader')
- .options({
- symbolId: 'icon-[name]'
- })
- .end()
- },
- })
|