Skip to content

Commit

Permalink
feat: support webpack5 && add example
Browse files Browse the repository at this point in the history
  • Loading branch information
kurthe committed Mar 6, 2021
1 parent 2ceaa7c commit 5836fa9
Show file tree
Hide file tree
Showing 10 changed files with 9,060 additions and 5,796 deletions.
2 changes: 1 addition & 1 deletion examples/webpack4/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
"babel-loader": "^8.1.0",
"webpack": "4.41.5",
"webpack-cli": "3.3.10",
"html-webpack-polyfill-runtime-plugin": "^1.0.4"
"html-webpack-polyfill-runtime-plugin": "latest"
}
}
2,411 changes: 1,093 additions & 1,318 deletions examples/webpack4/yarn.lock

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions examples/webpack5/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

const a = new Map([[1, 2]]);

const b = new Set([[3, 6]]);

console.warn(a,b)
24 changes: 24 additions & 0 deletions examples/webpack5/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "plugin-webpack4-demo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build:runtime": "webpack --config webpack.config.runtime.js",
"build:usage": "webpack --config webpack.config.usage.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"core-js": "^3.6.5",
"html-webpack-plugin": "^5.2.0"
},
"devDependencies": {
"@babel/core": "^7.12.3",
"@babel/preset-env": "^7.12.1",
"babel-loader": "^8.1.0",
"html-webpack-polyfill-runtime-plugin": "latest",
"webpack": "^5.24.3",
"webpack-cli": "^4.5.0"
}
}
5 changes: 5 additions & 0 deletions examples/webpack5/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## 使用

1. install root node_modules
2. install example project node_modules
3. run `npm run build:runtime` or `npm run build:usage`
29 changes: 29 additions & 0 deletions examples/webpack5/webpack.config.runtime.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlPolyfillRuntimePlugin = require('html-webpack-polyfill-runtime-plugin');

module.exports = {
entry: "./app.js",
mode: "production",
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: [['@babel/preset-env', {
targets: [
'defaults',
'Chrome > 33',
'ios_saf > 7',
'android > 4.4',
],
}]]
}
}
}
]
},
plugins: [new HtmlWebpackPlugin(), new HtmlPolyfillRuntimePlugin()],
}
29 changes: 29 additions & 0 deletions examples/webpack5/webpack.config.usage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
entry: "./app.js",
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: [['@babel/preset-env', {
useBuiltIns: 'usage',
corejs: 3,
targets: [
'defaults',
'Chrome > 33',
'ios_saf > 7',
'android > 4.4',
],
}]]
}
}
}
]
},
plugins: [new HtmlWebpackPlugin()],
}
Loading

0 comments on commit 5836fa9

Please sign in to comment.