当前位置:网站首页>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
边栏推荐
- Musk and twitter storm drama
- 何时适合进行自动化测试?(下)
- SQL Server检索SQL和用户信息的需求
- When is it appropriate for automated testing? (bottom)
- Interview summary
- 相机成像+单应性变换+相机标定+立体校正
- PIP free export with path (@ file: / / /) notes
- Low code and no code considerations
- The annual transaction volume of the app store is US $1 million, and only 15% commission is paid. Small and medium-sized developers are very contradictory
- The prefix of static of egg can be modified, including boots
猜你喜欢

Low code and no code considerations

2021-10-12

What are the most popular recruitment technical skills in 2022? You can't think of it

Using PHP post temporary file mechanism to upload arbitrary files

Good test data management, in the end how to do?

npm升级后问题,慌得一批

To understand Devops, you must read these ten books!

How to add beautiful code blocks in word | a very complete method to sort out and compare

Devops life cycle, all you want to know is here!

Domain driven model DDD (III) -- using saga to manage transactions
随机推荐
The concept of meta universe is popular. Is virtual real estate worth investing
Musk and twitter storm drama
[untitled] kimpei kdboxpro's cool running lantern coexists with beauty and strength
源码剖析Redis中如何使用跳表的
Interview summary
Three of three JS (webgl) is simple to draw lines / arcs according to points (based on linegeometry / line2 / linematerial, draw two arc segments based on the center of the circle)
Power consumption parameters of Jinbei household mute box series
Three of three JS (webgl) simple sorting of rotation attribute function, and a simple case of rotating around the axis based on this
Top 25 Devops tools in 2021 (Part 2)
Modèle axé sur le domaine DDD (III) - gestion des transactions à l'aide de Saga
selenium预先加载cookie的必要性
我这位老程序员对时代危险和机遇的一点感悟?
Necessity of selenium preloading cookies
Use of uniapp native plug-ins
The prefix of static of egg can be modified, including boots
工具在数字化转型中扮演了什么样的角色?
Nécessité de précharger les cookies dans le sélénium
如何在Word中添加漂亮的代码块 | 很全的方法整理和比较
What role do tools play in digital transformation?
Blender programmed terrain production