当前位置:网站首页>Wbpack configuring production development environment
Wbpack configuring production development environment
2022-04-23 05:25:00 【Python User】
Configuring the development environment and First understand the differences between them when it comes to the production environment :
development environment : Have a strong 、 With real-time reload (live reloading) Or thermal module replacement (HMR) The ability of source map and devserver proxy.
Production environment : Need to do a lighter operation ,css Compress , Packaging processing and more optimized resources , To improve loading time .
such , We put the public configuration , Put it in webpack.base.config.js in , Production environment configuration webpack.prod.config.js in , Development environment configuration webpack.dev.config.js in .
To combine these configurations , We will use a name called webpack-merge Tools to merge environments .
1, Used webpack.DefinePlugin() plug-in unit , To specify the environment
In the development environment webapck.dev.config.js:
plugins: [
new webpack.DefinePlugin({
'process.env': require('../config/dev.env')
}),
]
In production environment webpack.prod.config.js:
plugins: [
new webpack.DefinePlugin({
'process.env': require('../config/prod.env')
}),
]
2, Environment configuration
prod.env.js
'use strict'
module.exports = {
NODE_ENV: '"production"'
}
dev.env.js
'use strict'
const merge = require('webpack-merge')
const prodEnv = require('./prod.env')
module.exports = merge(prodEnv, {
NODE_ENV: '"development"'
})
After that, you can go to page.json Set in :
"scripts":{
// development environment
"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
// Production environment
"build": "webpack --config build/webpack.prod.conf.js"
}
版权声明
本文为[Python User]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220544545528.html
边栏推荐
- 开源规则引擎——ice:致力于解决灵活繁复的硬编码问题
- 2021-11-01
- 源码剖析Redis中如何使用跳表的
- Necessity of selenium preloading cookies
- Domain driven model DDD (III) -- using saga to manage transactions
- [untitled]
- Three of three JS (webgl) simple sorting of rotation attribute function, and a simple case of rotating around the axis based on this
- egg的static的前缀是可以修改惹,靴靴
- JS array common methods
- 点击添加按钮--出现一个框框(类似于添加学习经历-本科-研究生)
猜你喜欢
4 个最常见的自动化测试挑战及应对措施
JSP -- Introduction to JSP
Excel 2016 打开文件第一次打不开,有时空白,有时很慢要打开第二次才行
《2021年IT行业项目管理调查报告》重磅发布!
C#测试调用PaddleSharp模块识别图片文字
selenium預先加載cookie的必要性
Anti crawler (0): are you still climbing naked with selenium? You're being watched! Crack webdriver anti crawler
[untitled]
双击.jar包无法运行解决方法
2021-11-01
随机推荐
Use of uniapp native plug-ins
JS time format conversion
Solve the problem of JS calculation accuracy
Mairadb数据库基本操作之数据管理
低代码和无代码的注意事项
C#测试调用PaddleSharp模块识别图片文字
Kanban Quick Start Guide
The introduction of lean management needs to achieve these nine points in advance
2021-09-27
C test calls the paddlesharp module to recognize pictures and words
mariadb数据库的主从复制
Ehcache Memcache redis three caches
Laravel routing job
Domain driven model DDD (III) -- using saga to manage transactions
[untitled]
Devops life cycle, all you want to know is here!
Solution of how to log in with mobile phone verification code in wireless network
JSP-----JSP简介
JS Array常见方法
Multi process model in egg -- egg document Porter