Skip to content

Commit c66817f

Browse files
author
wangshan
committed
chore: 构建过程或辅助工具的变动 包括但不限于文档、代码生成等)
1 parent 0c7c59c commit c66817f

File tree

27 files changed

+986
-882
lines changed

27 files changed

+986
-882
lines changed

.babelrc

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
{
22
"presets": [
33
[
4-
"env",
4+
"@babel/preset-env",
55
{
6-
"targets": {
7-
// The % refers to the global coverage of users from browserslist
8-
"browsers": [">0.25%", "not ie 11", "not op_mini all"]
9-
}
6+
"useBuiltIns": "entry"
107
}
118
]
129
]

.browserslistrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# 目标环境监测配置, 或者通过package.json【browserslist】字段指定目标环境
2+
last 1 version
3+
> 1%
4+
IE 10

config/webpack.common.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22
* @Author: wangshan
33
* @Date: 2021-06-22 01:31:05
44
* @LastEditors: wangshan
5-
* @LastEditTime: 2021-06-22 02:10:04
5+
* @LastEditTime: 2021-06-23 00:42:08
66
* @Description:
77
*/
8+
// import "@babel/polyfill"; // 所有模块项导入前导入babel/polyfill
9+
810
const path = require("path");
911

1012
module.exports = {
11-
entry: ["babel-polyfill", path.resolve(__dirname, "../src/index.ts")],
13+
entry: [path.resolve(__dirname, "../src/index.ts")],
1214
resolve: {
13-
extensions: [".ts", ".js", ".json"],
15+
extensions: [".ts", ".js", ".json"], // 模块文件解析顺序
1416
},
1517
};

config/webpack.dev.js

+16-13
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,49 @@
22
* @Author: wangshan
33
* @Date: 2021-06-22 01:31:57
44
* @LastEditors: wangshan
5-
* @LastEditTime: 2021-06-22 02:05:41
5+
* @LastEditTime: 2021-06-23 00:52:08
66
* @Description:
77
*/
88

99
const path = require("path");
1010
const { merge } = require("webpack-merge");
11-
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
12-
const HtmlWebpackPlugin = require("html-webpack-plugin");
11+
const { CleanWebpackPlugin } = require("clean-webpack-plugin"); // 清空上次打包文件遗留文件
12+
const HtmlWebpackPlugin = require("html-webpack-plugin"); // 设置html模板
1313
// 引入通用webpack配置文件
1414
const common = require("./webpack.common.js");
15+
const Webpack = require("webpack");
1516

1617
module.exports = merge(common, {
18+
mode: "development",
19+
output: {
20+
path: path.resolve(__dirname, "../dist"),
21+
filename: "[name].[hash:8].js",
22+
},
1723
module: {
1824
rules: [
1925
{
20-
test: /\.ts(x?)$/,
21-
loader: "ts-loader",
26+
test: /\.ts$/,
27+
use: "ts-loader",
2228
},
2329
],
2430
},
2531
// 使用 source-map
2632
devtool: "source-map",
2733
// 对 webpack-dev-server 进行配置
2834
devServer: {
29-
contentBase: path.resolve(__dirname, "../dist"),
35+
contentBase: "../dist",
3036
// 设置localhost端口
3137
port: 9000,
38+
hot: true, //热更新
3239
// 自动打开浏览器
3340
open: true,
3441
},
3542
plugins: [
3643
new CleanWebpackPlugin(),
3744
new HtmlWebpackPlugin({
38-
title: "ts",
45+
// 使用插件,使用自定义插件
46+
template: path.resolve(__dirname, "../public/index.html"),
3947
}),
48+
new Webpack.HotModuleReplacementPlugin(), // 配置热更新
4049
],
41-
// 设置出口文件地址与文件名
42-
43-
output: {
44-
path: path.resolve(__dirname, "../dist"),
45-
filename: "[name].[hash:8].js",
46-
},
4750
});

config/webpack.prod.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @Author: wangshan
33
* @Date: 2021-06-22 01:33:57
44
* @LastEditors: wangshan
5-
* @LastEditTime: 2021-06-22 02:08:59
5+
* @LastEditTime: 2021-06-23 00:29:43
66
* @Description:
77
*/
88
const path = require("path");
@@ -15,19 +15,19 @@ const common = require("./webpack.common.js");
1515
// const uglifyJSPlugin = new UglifyJSPlugin();
1616

1717
// 对babel的配置,内容同.babelrc文件
18-
const babelOptions = {
19-
presets: [
20-
[
21-
"env",
22-
{
23-
targets: {
24-
// The % refers to the global coverage of users from browserslist
25-
browsers: [">0.25%", "not ie 11", "not op_mini all"],
26-
},
27-
},
28-
],
29-
],
30-
};
18+
// const babelOptions = {
19+
// presets: [
20+
// [
21+
// "env",
22+
// {
23+
// targets: {
24+
// // The % refers to the global coverage of users from browserslist
25+
// browsers: [">0.25%", "not ie 11", "not op_mini all"],
26+
// },
27+
// },
28+
// ],
29+
// ],
30+
// };
3131
module.exports = merge(common, {
3232
module: {
3333
rules: [

0 commit comments

Comments
 (0)