当前位置:网站首页>Webpack packaging Vue project adds confusion to solve the cache problem
Webpack packaging Vue project adds confusion to solve the cache problem
2022-07-27 04:19:00 【Hide roses on your back】
Method 1
Add dependency
npm i --save uglifyjs-webpack-plugin
vue.config.js Introduce methods
const UglifyPlugin = require("uglifyjs-webpack-plugin");
First, set the environment variables
Set... In the script
NODE_ENV=development Test environment
cross-env NODE_ENV=development vue-cli-service serve
"scripts": {
"serve": "cross-env NODE_ENV=development vue-cli-service serve",
"v1": "cross-env NODE_ENV=development vue-cli-service serve --mode v1",
"wis": "cross-env NODE_ENV=development vue-cli-service serve --mode wis",
"build": "cross-env NODE_ENV=production vue-cli-service build",
"build:wis": "cross-env NODE_ENV=production vue-cli-service build --mode wis",
"build:v1": "cross-env NODE_ENV=production vue-cli-service build -mode v1",
"lint": "vue-cli-service lint"
},
Set up vue.config.js To configure
Function mode
configureWebpack: (config) => {console.log(process.env.NODE_ENV);
if (process.env.NODE_ENV == "production") {
// Package each dependency package as a separate js file
let optimization = {
minimizer: [
new UglifyPlugin({
uglifyOptions: {
warnings: false,
compress: {
drop_console: true,
drop_debugger: false,
pure_funcs: ["console.log"],
},
},
}),
],
};
Object.assign(config, {
optimization,
});
config.resolve = {
...config.resolve,
alias: {
"@": resolve("src"),
},
};
}
},
Object mode
configureWebpack: {
plugins: [ new JavaScriptObfuscator({ rotateStringArray: true, }, []) ],
resolve: {
alias: {
"@": resolve("src"),
},
},
},
Method 2
Add dependency
npm i [email protected] -D
vue.config.js To configure
const TerserPlugin = require('terser-webpack-plugin')
configureWebpack: config => {
if (process.env.NODE_ENV === 'production') {
config.plugins.push(new TerserPlugin())
}
}
Method 3
const JavaScriptObfuscator = require('webpack-obfuscator');module.exports = {
entry: {
'mian1': './index1.js',
'main2': './index2.js'
},
output: {
path: 'dist',
filename: '[name].js'
},
plugins: [
new JavaScriptObfuscator({
rotateUnicodeArray: true
}, ['main2.js'])
]
};
边栏推荐
- Ant JD Sina 10 architects 424 page masterpiece in-depth distributed cache from principle to practice pdf
- Maximum nesting depth of parentheses
- spark练习案例(升级版)
- E-commerce system combined with commodity spike activities, VR panorama continues to bring benefits
- What is the principle difference between lateinit and lazy in kotlin
- [semidrive source code analysis] [drive bringup] 41 - LCM drive backlight backlight control principle analysis
- 每日一题:奇偶树
- 微信input组件添加清除图标,点击清空不生效
- 零基础小白也能懂的 Redis 数据库,手把手教你易学易用!
- JS to realize page Jump and parameter acquisition and loading
猜你喜欢

Worship the 321 page PDF of the core technology of Internet entrepreneurship that Alibaba is pushing internally. It's really kneeling

scala 不可变Map 、 可变Map 、Map转换为其他数据类型

Skywalking distributed system application performance monitoring tool - medium

288页18万字智能化校园总体设计 目录

js修改对象数组的key值

【MySQL系列】MySQL索引事务

网工知识角|只需四个步骤,教会你使用SecureCRT连接到eNSP,常用工具操作指南必看

Big talk · book sharing | lean product development: principles, methods and Implementation

【小样本分割】MSANet: Multi-Similarity and Attention Guidance for Boosting Few-Shot Segmentation

An online duplicate of a hidden bug
随机推荐
Towhee weekly model
[Code] sword finger offer 04 search in two-dimensional array
2022危险化学品生产单位安全生产管理人员考试题模拟考试题库模拟考试平台操作
Eureka-服务注册中心
Sum of binary numbers from root to leaf
452页13万字现代智慧乡镇雪亮工程整体解决方案2022版
Golang JWT cross domain authentication
VR panorama gold rush "careful machine" (Part 1)
BigDecimal踩坑总结&最佳实践
Cool Lehman VR panorama paves the way for you to start a business
从根到叶的二进制数之和
Collating strings
CloudCompare&PCL 匹配点距离抑制
356页14万字高端商业办公综合楼弱电智能化系统2022版
Practice of microservice in solving Library Download business problems
【SemiDrive源码分析】【驱动BringUp】41 - LCM 驱动 backlight 背光控制原理分析
二叉树的坡度
Daily question 1: parity tree
Subject 3: Jinan Zhangqiu line 3
【MySQL系列】MySQL索引事务