Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2018/07/27 webpack4 总结 #19

Open
ChenPt opened this issue Jul 30, 2018 · 1 comment
Open

2018/07/27 webpack4 总结 #19

ChenPt opened this issue Jul 30, 2018 · 1 comment

Comments

@ChenPt
Copy link
Owner

ChenPt commented Jul 30, 2018

webpack4 内置了很多插件,所以之前一些需要手动引入的插件都不用再引入了。

webpack的基础概念

entry, output, rules, plugins
主要就是这四个东西

webpack4新写法

vue-loader 需要显式在plugins数组里引入,不然会报错

const { VueLoaderPlugin } = require('vue-loader')
/*
...
*/
plugins: [
    new VueLoaderPlugin()  // webpack 4 vue-loader需要这样使用
]

新增了mode,可以不用手动设置process.env.NODE_ENV

mode: 'development'  // 自动设置`process.env.NODE_ENV`的值为"development"

而且还会根据当前的构建环境来执行默认内置的插件,进行优化

具体参考
webpack中文网

code spliting

缓存

manifest & runtime & vendor

@Liugq5713
Copy link

Liugq5713 commented Sep 12, 2018

typo: vue-loader 需要显示在plugins数组里引入,不然会报错 ===》 显式在plugin引入

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants