Files
temu-plugin/vue.config.js

58 lines
1.5 KiB
JavaScript
Raw Normal View History

2023-08-06 16:50:17 +08:00
const path = require('path')
const fs = require('fs')
// Generate pages object
const pages = {}
2023-09-27 09:29:45 +08:00
function getEntryFile(entryPath) {
2023-09-26 17:56:17 +08:00
return fs.readdirSync(entryPath)
2023-08-06 16:50:17 +08:00
}
const chromeName = getEntryFile(path.resolve(`src/entry`))
2023-09-27 09:29:45 +08:00
function getFileExtension(filename) {
2023-08-06 16:50:17 +08:00
return /[.]/.exec(filename) ? /[^.]+$/.exec(filename)[0] : undefined
}
2023-09-27 09:29:45 +08:00
2023-08-06 16:50:17 +08:00
chromeName.forEach((name) => {
const fileExtension = getFileExtension(name)
const fileName = name.replace('.' + fileExtension, '')
pages[fileName] = {
2023-09-27 09:29:45 +08:00
entry: `src/entry/${name}`, template: 'public/index.html', filename: `${fileName}.html`
2023-08-06 16:50:17 +08:00
}
})
const isDevMode = process.env.NODE_ENV === 'development'
module.exports = {
2024-11-04 17:47:02 +08:00
pages,
filenameHashing: false,
chainWebpack: (config) => {
2023-09-27 09:29:45 +08:00
config.plugin('copy').use(require('copy-webpack-plugin'), [{
patterns: [{
from: path.resolve(`src/manifest.${process.env.NODE_ENV}.json`), to: `${path.resolve('dist')}/manifest.json`
}, {
from: path.resolve(`public/`), to: `${path.resolve('dist')}/`
}]
}])
2024-11-04 17:47:02 +08:00
},
devServer: {
port: 8080, open: true, hot: true,
proxy: {
2023-08-06 16:50:17 +08:00
'/api': {
2023-09-27 09:29:45 +08:00
target: 'http://pdd.jjcp52.com', changeOrigin: true, ws: true, pathRewrite: {
2023-08-06 16:50:17 +08:00
'^/api': '/'
}
}
}
2024-11-04 17:47:02 +08:00
},
lintOnSave: false,
configureWebpack: {
2023-08-06 16:50:17 +08:00
output: {
2023-09-27 09:29:45 +08:00
filename: `[name].js`, chunkFilename: `[name].js`
2024-11-04 17:47:02 +08:00
},
devtool: isDevMode ? 'inline-source-map' : false
},
css: {
2023-08-06 16:50:17 +08:00
extract: false // Make sure the css is the same
}
}