Skip to content

Commit

Permalink
Add in explicit support for Neutrino, and include an examples folder
Browse files Browse the repository at this point in the history
  • Loading branch information
stephencookdev committed Mar 4, 2018
1 parent 2cf8023 commit 36487a4
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ const webpackConfig = smp.wrap({
});
```

and you're done! SMP will now be printing timing output to the console by default
and you're done! SMP will now be printing timing output to the console by default.

Check out the [examples folder](/examples) for some more examples.

## Options

Expand Down
18 changes: 18 additions & 0 deletions examples/basic.webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const SpeedMeasurePlugin = require("speed-measure-webpack-plugin");

const smp = new SpeedMeasurePlugin();

module.exports = smp.wrap({
entry: {
app: ["./app.js"]
},
output: "./public",
module: {
rules: [
{
test: /\.js$/,
use: [{ loader: "babel-loader" }]
}
]
}
});
9 changes: 9 additions & 0 deletions examples/neutrinorc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
use: [
"@neutrinojs/airbnb",
"@neutrinojs/jest",

// Make sure this is last! This strongly depends on being placed last
"speed-measure-webpack-plugin/neutrino"
]
}
38 changes: 38 additions & 0 deletions examples/webpack-merge.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const merge = require("webpack-merge");
const SpeedMeasurePlugin = require("speed-measure-webpack-plugin");

const smp = new SpeedMeasurePlugin();
const TARGET = process.env.npm_lifecycle_event;

const commonConfig = {
entry: {
app: ["./app.js"]
},
module: {
loaders: [
{
test: /\.css$/,
loaders: ["style", "css"],
},
],
},
};

let mergedConfig = commonConfig;

if(TARGET === "start") {
mergedConfig = merge(common, {
module: {
loaders: [
{
test: /\.jsx?$/,
loader: "babel?stage=1"
}
]
}
});
}

// The only difference to how you normally use webpack-merge is that you need
// to `smp.wrap` whatever your final config is
module.exports = smp.wrap(mergedConfig);
15 changes: 15 additions & 0 deletions neutrino.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const SpeedMeasurePlugin = require(".");
const smp = new SpeedMeasurePlugin();

module.exports = neutrino => {
const origConfig = neutrino.config;
const wrappedConfig = smp.wrap(origConfig.toConfig());
neutrino.config = new Proxy(origConfig, {
get(target, property) {
if (property === "toConfig") {
return () => wrappedConfig;
}
return target[property];
},
});
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "speed-measure-webpack-plugin",
"version": "1.0.2",
"version": "1.1.0",
"description": "Measure + analyse the speed of your webpack loaders and plugins",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 36487a4

Please sign in to comment.