webpack-es3-plugin
v1.5.2
Published
As the name suggested
Downloads
153
Readme
webpack-es3-plugin
As the name suggested
Intro
Convert emitted Javascript files by webpack to es3 format
Notice
- Designed for webpack v4
- Set
optimization.minimize
tofalse
- If using
babel-loader
, then setloose
totrue
andmodules
to"commonjs"
in your@babel/env-preset
{
"presets": [["@babel/preset-env", { "loose": true, "modules": "commonjs" }]]
}
Installation
$ npm i -D webpack-es3-plugin
# or
$ yarn add -D webpack-es3-plugin
Usage
// in your webpack.config.js
const ES3Plugin = require("webpack-es3-plugin");
module.exports = {
plugins: [new ES3Plugin()]
};
Config
No field is needed by default.
[waitFor=() => Promise.resolve()]
type waitFor = number | () => Promise<any>;
If passing numbers, then wait for some time to start. Unit is ms
.
If a function is passed in, then the plugin will wait till the returned Promise resolves.
// wait for 1000ms
new ES3Plugin({
waitFor: 1000
});
// or function that returns a Promise
const task = () => {
return new Promise(resolve => {
// do something
resolve();
});
};
new ES3Plugin({
waitFor: task
});
[onFinish=() => {}]
Called when transformation (compile to ES3 compatible) is done.
new ES3Plugin({
onFinish() {
// do something
}
});