1 Star 0 Fork 0

itcode2021/vue-more-page

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
vue.config.js 3.05 KB
一键复制 编辑 原始数据 按行查看 历史
itcode2021 提交于 2022-05-31 11:08 . 初始项目
const path = require('path')
const glob = require('glob')
const PAGES_PATH = './src/pages/*/*.js'
const SpeedMeasurePlugin = require('speed-measure-webpack-plugin')
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const ParallelUglifyPlugin = require('webpack-parallel-uglify-plugin');
const CompressionPlugin = require("compression-webpack-plugin");
const smp = new SpeedMeasurePlugin()
const resolve = dir => path.join(__dirname, dir)
// 生成多页面配置
const generatePages = () => {
let pages = {}
glob.sync(PAGES_PATH).forEach(filepath => {
let fileList = filepath.split('/')
let fileName = fileList[fileList.length - 2]
let htmlFileName = fileName.replace(/[A-Z]/g, '-$&').toLowerCase() // html文件名以中横线为主
pages[fileName] = {
entry: filepath,
template: `public/index.html`, // 'public/index.html'
filename: `${htmlFileName}.html`,
chunks: ['chunk-vendors', 'chunk-common', fileName]
}
})
return pages
}
module.exports = {
publicPath: process.env.VUE_APP_WEB_PATH,
productionSourceMap: false, // 是否为生产环境构建生成 source map?
css: {
sourceMap: false,
},
pages: generatePages(),
chainWebpack: config => {
config.resolve.alias
.set('@', resolve('src'))
.set('@components', resolve('src/components'))
.set('@utils', resolve('src/utils'))
},
// configureWebpack: process.env.NODE_ENV === "production" ? smp.wrap({
// plugins: [
// new BundleAnalyzerPlugin(),
// new ParallelUglifyPlugin({
// cacheDir: '.cache/',
// uglifyJS: {
// output: {
// beautify: false,
// comments: false
// },
// warnings: false,
// compress: {
// drop_console: true,
// collapse_vars: false,
// reduce_vars: false
// }
// }
// }),
// new CompressionPlugin({
// test: /\.(js|html|css)$/,
// threshold: 1024,
// minRatio: 0.8
// })
// ]
// }) : {},
configureWebpack: {
plugins: [
// new BundleAnalyzerPlugin(),
new ParallelUglifyPlugin({
cacheDir: '.cache/',
uglifyJS: {
output: {
beautify: false,
comments: false
},
warnings: false,
compress: {
drop_console: true,
collapse_vars: false,
reduce_vars: false
}
}
}),
new CompressionPlugin({
test: /\.(js|html|css)$/,
threshold: 1024,
minRatio: 0.8
})
]
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lmkitcode/vue-more-page.git
[email protected]:lmkitcode/vue-more-page.git
lmkitcode
vue-more-page
vue-more-page
master

搜索帮助