You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

63 lines
1.9 KiB

const path = require("path");
let resolve=dir=>path.join(__dirname,dir)
const isProduction = process.env.NODE_ENV === "production";
module.exports = {
publicPath:"./",
productionSourceMap:false,
lintOnSave: false,
filenameHashing: !isProduction,
// outputDir:"",
pages: {
index: {
entry: 'src/main.js',
template: 'public/index.html',
filename: 'index.html'
},
},
configureWebpack:{
devtool: "source-map"//isProduction ? false : "source-map",
},
devServer: {
port: process.env.PORT||8899, // 服务端口 默认8899
https: false, // 是否使用https
open: true, // 是否打开游览器
// proxy: { // 跨域代理
// '/api': {
// target: loadEnv(mode, process.cwd()).VITE_APP_API,
// changeOrigin: true,
// rewrite: (path) => path.replace(/^\/api/, '')
// }
// }
},
// 扩展 webpack 配置,使 packages 加入编译
chainWebpack: config => {
// config.module
// .rule('js')
// .include
// .add('/packages')
// .end()
// .use('babel')
// .loader('babel-loader')
// .tap(options => {
// return options
// })
//自定义图片
config.module.rule("images").use('url-loader').tap(options=>({
name:`./img/[hash]_[name].[ext]`,
quality:85,
limit: 0,
exModule:false,
}) )
//svg
config.module.rule("svg").exclude.add(resolve('src/assets/svg')).end()
config.module.rule('icons').test(/\.svg$/).include.add(resolve('src/assets/svg')).end().use('svg-sprite-loader').loader('svg-sprite-loader').options({symbolId:'icon-[name]'}).end()
config.optimization.splitChunks(false);
// config.optimization.minimize(false);//不压缩代码
config.resolve.alias
.set("@", path.join(__dirname, 'src'))
}
}