Skip to content

Commit 36487a4

Browse files
Add in explicit support for Neutrino, and include an examples folder
1 parent 2cf8023 commit 36487a4

File tree

6 files changed

+84
-2
lines changed

6 files changed

+84
-2
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ const webpackConfig = smp.wrap({
6161
});
6262
```
6363

64-
and you're done! SMP will now be printing timing output to the console by default
64+
and you're done! SMP will now be printing timing output to the console by default.
65+
66+
Check out the [examples folder](/examples) for some more examples.
6567

6668
## Options
6769

examples/basic.webpack.config.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const SpeedMeasurePlugin = require("speed-measure-webpack-plugin");
2+
3+
const smp = new SpeedMeasurePlugin();
4+
5+
module.exports = smp.wrap({
6+
entry: {
7+
app: ["./app.js"]
8+
},
9+
output: "./public",
10+
module: {
11+
rules: [
12+
{
13+
test: /\.js$/,
14+
use: [{ loader: "babel-loader" }]
15+
}
16+
]
17+
}
18+
});

examples/neutrinorc.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
use: [
3+
"@neutrinojs/airbnb",
4+
"@neutrinojs/jest",
5+
6+
// Make sure this is last! This strongly depends on being placed last
7+
"speed-measure-webpack-plugin/neutrino"
8+
]
9+
}

examples/webpack-merge.config.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
const merge = require("webpack-merge");
2+
const SpeedMeasurePlugin = require("speed-measure-webpack-plugin");
3+
4+
const smp = new SpeedMeasurePlugin();
5+
const TARGET = process.env.npm_lifecycle_event;
6+
7+
const commonConfig = {
8+
entry: {
9+
app: ["./app.js"]
10+
},
11+
module: {
12+
loaders: [
13+
{
14+
test: /\.css$/,
15+
loaders: ["style", "css"],
16+
},
17+
],
18+
},
19+
};
20+
21+
let mergedConfig = commonConfig;
22+
23+
if(TARGET === "start") {
24+
mergedConfig = merge(common, {
25+
module: {
26+
loaders: [
27+
{
28+
test: /\.jsx?$/,
29+
loader: "babel?stage=1"
30+
}
31+
]
32+
}
33+
});
34+
}
35+
36+
// The only difference to how you normally use webpack-merge is that you need
37+
// to `smp.wrap` whatever your final config is
38+
module.exports = smp.wrap(mergedConfig);

neutrino.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const SpeedMeasurePlugin = require(".");
2+
const smp = new SpeedMeasurePlugin();
3+
4+
module.exports = neutrino => {
5+
const origConfig = neutrino.config;
6+
const wrappedConfig = smp.wrap(origConfig.toConfig());
7+
neutrino.config = new Proxy(origConfig, {
8+
get(target, property) {
9+
if (property === "toConfig") {
10+
return () => wrappedConfig;
11+
}
12+
return target[property];
13+
},
14+
});
15+
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "speed-measure-webpack-plugin",
3-
"version": "1.0.2",
3+
"version": "1.1.0",
44
"description": "Measure + analyse the speed of your webpack loaders and plugins",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)