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.
115 lines
3.4 KiB
115 lines
3.4 KiB
/**
|
|
* 配置参考: https://cli.vuejs.org/zh/config/
|
|
*/
|
|
'use strict'
|
|
const path = require('path')
|
|
const JavaScriptObfuscator = require('webpack-obfuscator')
|
|
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
|
|
const CopyPlugin = require('copy-webpack-plugin')
|
|
function resolve(dir) {
|
|
return path.join(__dirname, dir)
|
|
}
|
|
module.exports = {
|
|
parallel: false,
|
|
publicPath: process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'staging' ? process.env.VUE_APP_BASE_SUF : '/', // 多页面情况 process.env.NODE_ENV === 'production' ? './' : '/',
|
|
assetsDir: 'static',
|
|
chainWebpack: config => {
|
|
config.entry('main').add('babel-polyfill')
|
|
config.entry.app = ['babel-polyfill', './src/page-subspecialty/main.js']
|
|
config.resolve.symlinks(true)
|
|
const svgRule = config.module.rule('svg')
|
|
svgRule.uses.clear()
|
|
svgRule
|
|
.test(/\.svg$/)
|
|
.use('svg-sprite-loader')
|
|
.loader('svg-sprite-loader')
|
|
},
|
|
transpileDependencies: ['*'],
|
|
// 默认打开eslint效验,如果需要关闭,设置成false即可
|
|
lintOnSave: false,
|
|
runtimeCompiler: true,
|
|
productionSourceMap: false,
|
|
devServer: {
|
|
inline: true,
|
|
open: true,
|
|
hot: true,
|
|
// https: true,
|
|
port: 8002,
|
|
host: '127.0.0.1',
|
|
// host: 'localhost',
|
|
// host: '0.0.0.0',
|
|
// host: '192.168.0.168',
|
|
overlay: {
|
|
errors: true,
|
|
warnings: true
|
|
},
|
|
proxy: { // 配置跨域
|
|
'/oeis': {
|
|
target: 'https://192.168.0.35', // 这里后台的地址模拟的;应该填写真实的后台接口
|
|
secure: false,
|
|
changOrigin: true, // 允许跨域
|
|
pathRewrite: {
|
|
'^/oeis': ''
|
|
}
|
|
}
|
|
}
|
|
},
|
|
configureWebpack: {
|
|
resolve: {
|
|
alias: {
|
|
'vue': 'vue/dist/vue.esm.js',
|
|
'@': resolve('src'),
|
|
'@static': path.resolve(__dirname, 'static')
|
|
}
|
|
},
|
|
// optimization: {
|
|
// minimize: true // 启用代码压缩
|
|
// minimizer: [new TerserPlugin({
|
|
// terserOptions: {
|
|
// compress: {
|
|
// drop_console: true // 移除console语句,可以根据需要调整其他选项
|
|
// }
|
|
// }
|
|
// })]
|
|
// },
|
|
plugins: [
|
|
new CopyPlugin({ patterns: [
|
|
{ from: path.resolve(__dirname, 'static'), to: 'static' }
|
|
] }),
|
|
...(process.env.NODE_ENV === 'staging'
|
|
? [new JavaScriptObfuscator({
|
|
rotateStringArray: true, // 加密字符串
|
|
controlFlowFlattening: true, // 控制流扁平化
|
|
stringArray: true, // 提取字符串到数组
|
|
stringArrayThreshold: 0.8, // 提取概率阈值
|
|
target: 'browser', // 目标环境
|
|
ignoreImports: true, // 这里设置为true
|
|
identifierNamesGenerator: 'hexadecimal', // 变量名替换为16进制
|
|
compact: true // 紧凑输出
|
|
})]
|
|
: [])
|
|
// new BundleAnalyzerPlugin(
|
|
// {
|
|
// analyzerMode: 'server',
|
|
// analyzerHost: '127.0.0.1',
|
|
// analyzerPort: 8889,
|
|
// reportFilename: 'report.html',
|
|
// defaultSizes: 'parsed',
|
|
// openAnalyzer: true,
|
|
// generateStatsFile: false,
|
|
// statsFilename: 'stats.json',
|
|
// statsOptions: null,
|
|
// logLevel: 'info'
|
|
// }
|
|
// )
|
|
]
|
|
},
|
|
pages: {
|
|
index: {
|
|
template: 'public/index.html',
|
|
entry: 'src/page-subspecialty/main.js',
|
|
filename: 'index.html',
|
|
title: 'index'
|
|
}
|
|
}
|
|
}
|