summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormokha <mokha@cisco.com>2018-09-30 16:19:03 -0600
committermokha <mokha@cisco.com>2018-09-30 16:19:03 -0600
commit99d499a1088ab804f9061f718bfe8180374b7941 (patch)
treed00c3e3e14b23c4fc26b504e96927090f6bb0ca8
parent8b93bddb4758ae728b87f22143f11d6fb46f47db (diff)
create a plugin.HEADmaster
* https://survivejs.com/webpack/extending/plugins/
-rw-r--r--package-lock.json6
-rw-r--r--package.json2
-rw-r--r--plugins/demo-plugin.js15
-rw-r--r--webpack.plugin.js17
4 files changed, 37 insertions, 3 deletions
diff --git a/package-lock.json b/package-lock.json
index cd1ef6f..dadbf0e 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -15189,9 +15189,9 @@
}
},
"webpack-sources": {
- "version": "1.1.0",
- "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.1.0.tgz",
- "integrity": "sha512-aqYp18kPphgoO5c/+NaUvEeACtZjMESmDChuD3NBciVpah3XpMEU9VAAtIaB1BsfJWWTSdv8Vv1m3T0aRk2dUw==",
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.3.0.tgz",
+ "integrity": "sha512-OiVgSrbGu7NEnEvQJJgdSFPl2qWKkWq5lHMhgiToIiN9w34EBnjYzSYs+VbL5KoYiLNtFFa7BZIKxRED3I32pA==",
"dev": true,
"requires": {
"source-list-map": "^2.0.0",
diff --git a/package.json b/package.json
index fd14529..32efbe0 100644
--- a/package.json
+++ b/package.json
@@ -5,6 +5,7 @@
"main": "index.js",
"scripts": {
"build": "webpack --mode production",
+ "build:plugin": "webpack --config webpack.plugin.js",
"build:i18n": "webpack --config webpack.i18n.js",
"build:ssr": "webpack --config webpack.ssr.js",
"build:stats": "webpack --mode production --json > stats.json",
@@ -65,6 +66,7 @@
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.9",
"webpack-merge": "^4.1.4",
+ "webpack-sources": "^1.3.0",
"worker-loader": "^2.0.0"
},
"dependencies": {
diff --git a/plugins/demo-plugin.js b/plugins/demo-plugin.js
new file mode 100644
index 0000000..32cb390
--- /dev/null
+++ b/plugins/demo-plugin.js
@@ -0,0 +1,15 @@
+const { RawSource } = require("webpack-sources");
+
+module.exports = class DemoPlugin {
+ constructor(options) {
+ this.options = options;
+ }
+ apply(compiler) {
+ const { name } = this.options;
+
+ compiler.plugin("emit", (compilation, cb) => {
+ compilation.assets[name] = new RawSource("demo");
+ cb();
+ });
+ }
+};
diff --git a/webpack.plugin.js b/webpack.plugin.js
new file mode 100644
index 0000000..eeea054
--- /dev/null
+++ b/webpack.plugin.js
@@ -0,0 +1,17 @@
+const path = require("path");
+const DemoPlugin = require("./plugins/demo-plugin.js");
+const PATHS = {
+ lib: path.join(__dirname, "src", "shake.js"),
+ build: path.join(__dirname, "build"),
+};
+
+module.exports = {
+ entry: {
+ lib: PATHS.lib,
+ },
+ output: {
+ path: PATHS.build,
+ filename: "[name].js",
+ },
+ plugins: [new DemoPlugin({ name: "demo" })],
+};