1 Star 0 Fork 4

hostinside/Cube H5

forked from CubeTeam/Cube H5 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
vue.config.js 2.02 KB
一键复制 编辑 原始数据 按行查看 历史
HenryZheng 提交于 2020-01-16 13:44 +08:00 . 第一次推送
const path = require('path')
const fs = require('fs')
const CompressionWebpackPlugin = require('compression-webpack-plugin')
const productionGzipExtensions = ['js', 'css']
let devServer = {
proxy: { // 代理
'/': {
target: 'http://localhost:4000',//设置你调用的接口域名和端口号 别忘了加http
ws: false,
changeOrigin: true, // needed for virtual hosted sites
pathRewrite: {},
}
}
}
module.exports = {
devServer: devServer,
// 输出文件目录
assetsDir: "static",
publicPath:"./",
// 修改 pages 入口
pages: {
index: {
entry: 'client/main.js', // 入口
template: 'public/engine-h5-long.html', // 模板
filename: 'index.html' // 输出文件
}
},
css: {
loaderOptions: {
sass: {
// @/ 是 src/ 的别名
data: fs.readFileSync(path.resolve(__dirname, `./client/common/styles/variables.scss`), 'utf-8') // 公共变量文件注入
}
}
},
productionSourceMap: process.env.NODE_ENV !== 'production',
configureWebpack: config => {
if (process.env.NODE_ENV === 'production') {
// 生产环境
config.plugins.push(
new CompressionWebpackPlugin({
filename: '[path].gz[query]', // 提示示compression-webpack-plugin@3.0.0的话asset改为filename
algorithm: 'gzip',
test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
threshold: 10240,
minRatio: 0.8
})
);
} else {
// 开发环境
}
},
// 扩展 webpack 配置
chainWebpack: config => {
// @ 默认指向 src 目录,这里要改成 examples
// 另外也可以新增一个 ~ 指向 packages
config.resolve.alias
.set('@', path.resolve('client'))
.set('@client', path.resolve('client'))
.set('@plugins', path.resolve('plugins'))
.set('@server', path.resolve('server'))
config.module
.rule('js')
.include.add(/engine-template/).end()
.include.add(/client/).end()
.include.add(/common/).end()
.use('babel')
.loader('babel-loader')
.tap(options => {
// 修改它的选项...
return options
})
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/hostinside/Cube-H5.git
git@gitee.com:hostinside/Cube-H5.git
hostinside
Cube-H5
Cube H5
master

搜索帮助