diff --git a/package.json b/package.json index 09ec2c6..a03ec12 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "@vue/cli-plugin-babel": "~5.0.0", "@vue/cli-plugin-eslint": "~5.0.0", "@vue/cli-service": "~5.0.0", + "copy-webpack-plugin": "^6.4.1", "eslint": "^7.32.0", "eslint-plugin-vue": "^8.0.3", "javascript-obfuscator": "2.6.0", diff --git a/vue.config.js b/vue.config.js index 6719c79..b59796f 100644 --- a/vue.config.js +++ b/vue.config.js @@ -1,83 +1,56 @@ const path = require('path') const fs = require('fs') const JavaScriptObfuscator = require('webpack-obfuscator') -const obfuscateConfig = require('./obfuscator.config') // Generate pages object const pages = {} -function getEntryFile (entryPath) { +function getEntryFile(entryPath) { return fs.readdirSync(entryPath) } const chromeName = getEntryFile(path.resolve(`src/entry`)) -function getFileExtension (filename) { +function getFileExtension(filename) { return /[.]/.exec(filename) ? /[^.]+$/.exec(filename)[0] : undefined } + chromeName.forEach((name) => { const fileExtension = getFileExtension(name) const fileName = name.replace('.' + fileExtension, '') pages[fileName] = { - entry: `src/entry/${name}`, - template: 'public/index.html', - filename: `${fileName}.html` + entry: `src/entry/${name}`, template: 'public/index.html', filename: `${fileName}.html` } }) const isDevMode = process.env.NODE_ENV === 'development' module.exports = { - pages, - filenameHashing: false, - chainWebpack: (config) => { - // 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')}/` - // } - // ] - // } - // ]) - }, - devServer: { - port: 8080, - open: true, - overlay: { - warnings: false, - errors: true - }, - proxy: { + pages, filenameHashing: false, chainWebpack: (config) => { + 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')}/` + }] + }]) + }, devServer: { + port: 8080, open: true, overlay: { + warnings: false, errors: true + }, proxy: { '/api': { - target: 'http://pdd.jjcp52.com', - changeOrigin: true, - ws: true, - pathRewrite: { + target: 'http://pdd.jjcp52.com', changeOrigin: true, ws: true, pathRewrite: { '^/api': '/' } } } - }, - lintOnSave: false, - configureWebpack: { + }, lintOnSave: false, configureWebpack: { output: { - filename: `[name].js`, - chunkFilename: `[name].js` - }, - devtool: isDevMode ? 'inline-source-map' : false, - plugins: isDevMode ? [] : [ - new JavaScriptObfuscator({ - rotateStringArray: true, - }, []) - ] - }, - css: { + filename: `[name].js`, chunkFilename: `[name].js` + }, devtool: isDevMode ? 'inline-source-map' : false, plugins: isDevMode ? [] : [new JavaScriptObfuscator({ + rotateStringArray: true, + }, [])] + }, css: { extract: false // Make sure the css is the same } }