6 Star 1 Fork 1

高朋/iot_platform_web

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
vue.config.js 2.85 KB
一键复制 编辑 原始数据 按行查看 历史
const path = require('path');
const { library } = require('./package.json');
const webpack = require('webpack');
const AddAssetHtmlPlugin = require('add-asset-html-webpack-plugin');
const resolve = dir => path.join(__dirname, dir)
module.exports = {
devServer: {
port: 8091,
proxy: {
"/api": {
ws: true,
target: 'http://47.102.103.218:8700/',
changeOrigin: true,
pathRewrite: {
'^/api': '/'
}
}
},
},
lintOnSave: false,
publicPath: '/',
css: {
loaderOptions: {
sass: {
data: `@import "@/style/public.scss";`
}
},
},
chainWebpack: (config) => {
// 修复HMR
config.resolve.symlinks(true);
// 别名配置
config.resolve.alias.set('@', resolve('./src'));
},
productionSourceMap: process.env.NODE_ENV === 'production' ? false : true, // 生产环境是否生成 sourceMap 文件
configureWebpack: (config) => {
if (process.env.NODE_ENV === 'production') {
// 为生产环境修改配置...
config.mode = 'production';
//分包
config.performance = { //关闭webpack性能提示
hints: false
};
config.optimization.splitChunks = {
chunks: 'all',
cacheGroups: {
commons: {
chunks: 'all',
name: 'chunk-commons',
test: /[\\/]src[\\/]utils[\\/]/,
minSize: 0,
minChunks: 2,
priority: 60,
reuseExistingChunk: true
},
libs: {
name: 'chunk-libs',
test: /[\\/]node_modules[\\/]/,
priority: 10,
chunks: 'all'
},
styles: {
name: 'styles',
test: /\.(sa|sc|c)ss$/,
chunks: 'all',
enforce: true,
},
elementUI: {
name: 'chunk-elementUI',
priority: 20,
test: /[\\/]node_modules[\\/]_?element-ui(.*)/
},
}
};
config.optimization.runtimeChunk = {
name: 'manifest'
}
//使用预编译 vue vuex vue-router axios 进行编译
config.plugins.push(
...Object.keys(library).map(name => {
return new webpack.DllReferencePlugin({
manifest: path.resolve(__dirname, `lib/${name}.manifest.json`),
})
})
)
config.plugins.push(
new webpack.optimize.ModuleConcatenationPlugin()
)
//页面中引用预编译的内容
config.plugins.push(
...Object.keys(library).map(name => {
return new AddAssetHtmlPlugin([{
filepath: path.resolve(__dirname, `lib/${name}.dll.js`),
outputPath: '/js/',
publicPath: "/js",
includeSourcemap: true
}])
})
)
} else {
// 为开发环境修改配置...
config.mode = 'development';
}
},
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/cliffgao2s/iot_platform_web.git
git@gitee.com:cliffgao2s/iot_platform_web.git
cliffgao2s
iot_platform_web
iot_platform_web
master

搜索帮助