兼容性问题处理

This commit is contained in:
aixianling
2023-09-27 09:29:45 +08:00
parent 317a22179e
commit 43c54fbeed
2 changed files with 24 additions and 50 deletions

View File

@@ -26,6 +26,7 @@
"@vue/cli-plugin-babel": "~5.0.0", "@vue/cli-plugin-babel": "~5.0.0",
"@vue/cli-plugin-eslint": "~5.0.0", "@vue/cli-plugin-eslint": "~5.0.0",
"@vue/cli-service": "~5.0.0", "@vue/cli-service": "~5.0.0",
"copy-webpack-plugin": "^6.4.1",
"eslint": "^7.32.0", "eslint": "^7.32.0",
"eslint-plugin-vue": "^8.0.3", "eslint-plugin-vue": "^8.0.3",
"javascript-obfuscator": "2.6.0", "javascript-obfuscator": "2.6.0",

View File

@@ -1,83 +1,56 @@
const path = require('path') const path = require('path')
const fs = require('fs') const fs = require('fs')
const JavaScriptObfuscator = require('webpack-obfuscator') const JavaScriptObfuscator = require('webpack-obfuscator')
const obfuscateConfig = require('./obfuscator.config')
// Generate pages object // Generate pages object
const pages = {} const pages = {}
function getEntryFile (entryPath) { function getEntryFile(entryPath) {
return fs.readdirSync(entryPath) return fs.readdirSync(entryPath)
} }
const chromeName = getEntryFile(path.resolve(`src/entry`)) const chromeName = getEntryFile(path.resolve(`src/entry`))
function getFileExtension (filename) { function getFileExtension(filename) {
return /[.]/.exec(filename) ? /[^.]+$/.exec(filename)[0] : undefined return /[.]/.exec(filename) ? /[^.]+$/.exec(filename)[0] : undefined
} }
chromeName.forEach((name) => { chromeName.forEach((name) => {
const fileExtension = getFileExtension(name) const fileExtension = getFileExtension(name)
const fileName = name.replace('.' + fileExtension, '') const fileName = name.replace('.' + fileExtension, '')
pages[fileName] = { pages[fileName] = {
entry: `src/entry/${name}`, entry: `src/entry/${name}`, template: 'public/index.html', filename: `${fileName}.html`
template: 'public/index.html',
filename: `${fileName}.html`
} }
}) })
const isDevMode = process.env.NODE_ENV === 'development' const isDevMode = process.env.NODE_ENV === 'development'
module.exports = { module.exports = {
pages, pages, filenameHashing: false, chainWebpack: (config) => {
filenameHashing: false, config.plugin('copy').use(require('copy-webpack-plugin'), [{
chainWebpack: (config) => { patterns: [{
// config.plugin('copy').use(require('copy-webpack-plugin'), [ from: path.resolve(`src/manifest.${process.env.NODE_ENV}.json`), to: `${path.resolve('dist')}/manifest.json`
// { }, {
// patterns: [ from: path.resolve(`public/`), to: `${path.resolve('dist')}/`
// { }]
// from: path.resolve(`src/manifest.${process.env.NODE_ENV}.json`), }])
// to: `${path.resolve('dist')}/manifest.json` }, devServer: {
// }, port: 8080, open: true, overlay: {
// { warnings: false, errors: true
// from: path.resolve(`public/`), }, proxy: {
// to: `${path.resolve('dist')}/`
// }
// ]
// }
// ])
},
devServer: {
port: 8080,
open: true,
overlay: {
warnings: false,
errors: true
},
proxy: {
'/api': { '/api': {
target: 'http://pdd.jjcp52.com', target: 'http://pdd.jjcp52.com', changeOrigin: true, ws: true, pathRewrite: {
changeOrigin: true,
ws: true,
pathRewrite: {
'^/api': '/' '^/api': '/'
} }
} }
} }
}, }, lintOnSave: false, configureWebpack: {
lintOnSave: false,
configureWebpack: {
output: { output: {
filename: `[name].js`, filename: `[name].js`, chunkFilename: `[name].js`
chunkFilename: `[name].js` }, devtool: isDevMode ? 'inline-source-map' : false, plugins: isDevMode ? [] : [new JavaScriptObfuscator({
}, rotateStringArray: true,
devtool: isDevMode ? 'inline-source-map' : false, }, [])]
plugins: isDevMode ? [] : [ }, css: {
new JavaScriptObfuscator({
rotateStringArray: true,
}, [])
]
},
css: {
extract: false // Make sure the css is the same extract: false // Make sure the css is the same
} }
} }