Skip to content

Commit 85cdd23

Browse files
author
yangfan19
committed
flx
1 parent d380151 commit 85cdd23

26 files changed

+12074
-8
lines changed

webpack-11/webpack.prod.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,21 @@ module.exports = {
1919
{
2020
test: /.js$/,
2121
use: 'babel-loader',
22+
exclude: /node_modules/,
2223
},
2324
{
2425
test: /.css$/, // 配置css的后缀名
26+
exclude: /node_modules/,
2527
use: [MiniCssExtractplugin.loader, 'css-loader'], //tips:执行的顺序是右到左的
2628
},
2729
{
2830
test: /.less$/, // 配置less的后缀名
31+
exclude: /node_modules/,
2932
use: [MiniCssExtractplugin.loader, 'css-loader', 'less-loader'], //tips:执行的顺序是右到左的
3033
},
3134
{
3235
test: /.(png|jpg|gif|jpeg)$/,
36+
exclude: /node_modules/,
3337
use: [
3438
{
3539
loader: 'file-loader',
@@ -41,6 +45,7 @@ module.exports = {
4145
},
4246
{
4347
test: /.(woff|woff2|eot|ttf|otf)$/,
48+
exclude: /node_modules/,
4449
use: [
4550
{
4651
loader: 'file-loader',

webpack-12/webpack.prod.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,26 @@ module.exports = {
5959
filename: '[name]_[contenthash:8].css',
6060
}),
6161
new OptimizeCssAssetsWebpackPlugin({
62-
assetNameRegExp: /.css$/g,
63-
cssProcessor: require('cssnano'),
62+
assetNameRegExp: /.css$/g, // 匹配的正则的名称后缀、跟loader配置一致
63+
cssProcessor: require('cssnano'), // 用于最小化的css处理器,默认是cssnano
6464
}),
6565
new HtmlWebpackPlugin({
6666
template: path.join(__dirname, 'src/search.html'),
6767
filename: 'search.html',
6868
chunks: ['search'],
69+
/**
70+
* inject : true || 'head' || 'body' || false
71+
* body : 所有javascript资源将被放置在body元素的底部。
72+
* head : 把脚本放置在head元素中.
73+
* true : script标签位于html文件的 body 底部 [默认]
74+
* false: 不插入生成的 js 文件,只是单纯的生成一个 html 文件
75+
* */
6976
inject: true,
7077
minify: {
71-
html5: true,
72-
collapseWhitespace: true,
73-
preserveLineBreaks: false,
74-
minifyCSS: true,
75-
minifyJS: true,
76-
removeComments: false,
78+
collapseWhitespace: true, // 清理html中的空格、换行符。 默认值:false
79+
minifyCSS: true, // 压缩html内的样式。默认值:false
80+
minifyJS: true, // 压缩html内的js。 默认值:false
81+
removeComments: false, // 清理html中的注释。 默认值:false
7782
},
7883
}),
7984
new HtmlWebpackPlugin({

webpack-21/.babelrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"presets": ["@babel/preset-env", "@babel/preset-react"],
3+
"plugins": ["@babel/plugin-syntax-dynamic-import"]
4+
}

webpack-21/.gitignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# See https://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/idea
6+
/dist
7+
/es
8+
/lib
9+
10+
# misc
11+
.idea
12+
.vscode
13+
.DS_Store
14+
15+
16+
npm-debug.log*
17+
yarn-debug.log*
18+
yarn-error.log*

webpack-21/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# webpack-20
2+
3+
## 服务器渲染 SSR
4+
5+
推荐使用 github 上的一些开源好的规则仓库,比如:[standard](https://github.com/standard/standard)
6+
7+
<br />
8+
9+
## 配置
10+
11+
/src/search/index.js
12+
13+
```shell
14+
npm install standard --save-dev
15+
16+
```
17+
18+
<br />
19+
20+
package.json
21+
22+
```shell
23+
"scripts": {
24+
...
25+
"eslint": "standard && node src/*/*.js",
26+
"flx": "standard --fix",
27+
},
28+
29+
```
30+
31+
<br />

0 commit comments

Comments
 (0)