Browse Source

Upgrade webpack-chain to v2, add --inspect

v5.0.0-beta
Eli Perelman 8 years ago
parent
commit
11cd3ba0ca
  1. 12
      packages/neutrino-middleware-banner/index.js
  2. 10
      packages/neutrino-middleware-chunk/index.js
  3. 4
      packages/neutrino-middleware-clean/index.js
  4. 4
      packages/neutrino-middleware-copy/index.js
  5. 5
      packages/neutrino-middleware-env/index.js
  6. 2
      packages/neutrino-middleware-hot/index.js
  7. 28
      packages/neutrino-middleware-html-template/index.js
  8. 2
      packages/neutrino-middleware-loader-merge/index.js
  9. 2
      packages/neutrino-middleware-minify/index.js
  10. 2
      packages/neutrino-middleware-named-modules/index.js
  11. 2
      packages/neutrino-middleware-progress/index.js
  12. 2
      packages/neutrino-middleware-start-server/index.js
  13. 4
      packages/neutrino-preset-node/index.js
  14. 15
      packages/neutrino/bin/neutrino
  15. 4
      packages/neutrino/package.json
  16. 3
      packages/neutrino/test/api_test.js
  17. 26
      packages/neutrino/yarn.lock

12
packages/neutrino-middleware-banner/index.js

@ -1,10 +1,8 @@
const { BannerPlugin } = require('webpack');
const merge = require('deepmerge');
module.exports = ({ config }, options) => config
.plugin('banner')
.use(BannerPlugin, merge({
banner: `require('source-map-support').install();`,
raw: true,
entryOnly: true
}, options));
module.exports = ({ config }, options) => config.plugin('banner', BannerPlugin, merge({
banner: `require('source-map-support').install();`,
raw: true,
entryOnly: true
}, options));

10
packages/neutrino-middleware-chunk/index.js

@ -1,9 +1,7 @@
const { CommonsChunkPlugin } = require('webpack').optimize;
const merge = require('deepmerge');
module.exports = ({ config }, options) => config
.plugin('chunk')
.use(CommonsChunkPlugin, merge({
minChunks: Infinity,
names: ['vendor', 'manifest']
}, options));
module.exports = ({ config }, options) => config.plugin('chunk', CommonsChunkPlugin, merge({
minChunks: Infinity,
names: ['vendor', 'manifest']
}, options));

4
packages/neutrino-middleware-clean/index.js

@ -4,7 +4,5 @@ const merge = require('deepmerge');
module.exports = ({ config }, options) => {
const { paths, root } = merge({ paths: [], root: process.cwd() }, options);
config
.plugin('clean')
.use(CleanPlugin, paths, { root });
config.plugin('clean', CleanPlugin, paths, { root });
};

4
packages/neutrino-middleware-copy/index.js

@ -4,7 +4,5 @@ const merge = require('deepmerge');
module.exports = ({ config }, options) => {
const opts = merge({ patterns: [], options: {} }, options);
config
.plugin('copy')
.use(CopyPlugin, opts.patterns, opts.options);
config.plugin('copy', CopyPlugin, opts.patterns, opts.options);
};

5
packages/neutrino-middleware-env/index.js

@ -1,5 +1,4 @@
const { EnvironmentPlugin } = require('webpack');
module.exports = ({ config }, envs = []) => config
.plugin('env')
.use(EnvironmentPlugin, ['NODE_ENV', ...(Array.isArray(envs) ? envs : [])]);
module.exports = ({ config }, envs = []) => config.plugin('env', EnvironmentPlugin,
['NODE_ENV', ...(Array.isArray(envs) ? envs : [])]);

2
packages/neutrino-middleware-hot/index.js

@ -1,3 +1,3 @@
const { HotModuleReplacementPlugin } = require('webpack');
module.exports = ({ config }) => config.plugin('hot').use(HotModuleReplacementPlugin);
module.exports = ({ config }) => config.plugin('hot', HotModuleReplacementPlugin);

28
packages/neutrino-middleware-html-template/index.js

@ -2,18 +2,16 @@ const HtmlPlugin = require('html-webpack-plugin');
const template = require('html-webpack-template');
const merge = require('deepmerge');
module.exports = ({ config }, options) => config
.plugin('html')
.use(HtmlPlugin, merge({
template,
inject: false,
appMountId: 'root',
xhtml: true,
mobile: true,
minify: {
useShortDoctype: true,
keepClosingSlash: true,
collapseWhitespace: true,
preserveLineBreaks: true,
}
}, options));
module.exports = ({ config }, options) => config.plugin('html', HtmlPlugin, merge({
template,
inject: false,
appMountId: 'root',
xhtml: true,
mobile: true,
minify: {
useShortDoctype: true,
keepClosingSlash: true,
collapseWhitespace: true,
preserveLineBreaks: true,
}
}, options));

2
packages/neutrino-middleware-loader-merge/index.js

@ -2,4 +2,4 @@ const merge = require('deepmerge');
module.exports = (ruleId, loaderId) => ({ config }, options) => config.module
.rule(ruleId)
.loader(loaderId, props => merge(props, { options }));
.loader(loaderId, _opts => merge(_opts, options));

2
packages/neutrino-middleware-minify/index.js

@ -1,3 +1,3 @@
const BabiliPlugin = require('babili-webpack-plugin');
module.exports = ({ config }) => config.plugin('minify').use(BabiliPlugin);
module.exports = ({ config }) => config.plugin('minify', BabiliPlugin);

2
packages/neutrino-middleware-named-modules/index.js

@ -1,3 +1,3 @@
const { NamedModulesPlugin } = require('webpack');
module.exports = ({ config }) => config.plugin('named-modules').use(NamedModulesPlugin);
module.exports = ({ config }) => config.plugin('named-modules', NamedModulesPlugin);

2
packages/neutrino-middleware-progress/index.js

@ -1,3 +1,3 @@
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
module.exports = ({ config }) => config.plugin('progress').use(ProgressBarPlugin);
module.exports = ({ config }) => config.plugin('progress', ProgressBarPlugin);

2
packages/neutrino-middleware-start-server/index.js

@ -1,3 +1,3 @@
const StartServerPlugin = require('start-server-webpack-plugin');
module.exports = ({ config }, options) => config.plugin('start-server').use(StartServerPlugin, options.name);
module.exports = ({ config }, options) => config.plugin('start-server', StartServerPlugin, options.name);

4
packages/neutrino-preset-node/index.js

@ -37,7 +37,7 @@ module.exports = neutrino => {
}
});
config.options.set('performance', { hints: false });
config.performance.hints(false);
config
.target('node')
.node
@ -88,7 +88,7 @@ module.exports = neutrino => {
} else {
config.devtool('inline-sourcemap');
config.entry('index').add('webpack/hot/poll?1000');
config.output.options.set('devtoolModuleFilenameTemplate', '[absolute-resource-path]');
config.output.devtoolModuleFilenameTemplate('[absolute-resource-path]');
neutrino.use(hot);
neutrino.use(startServer, join(SRC, 'index.js'));
}

15
packages/neutrino/bin/neutrino

@ -6,9 +6,12 @@ process.noDeprecation = true;
const Neutrino = require('../src/neutrino');
const yargs = require('yargs');
const { pathOr } = require('ramda');
const { pathOr, pipe, partialRight } = require('ramda');
const { join } = require('path');
const stringify = require('javascript-stringify');
const sort = require('deep-sort-object');
const inspect = pipe(sort, partialRight(stringify, [null, 2]), console.log, process.exit);
const cwd = process.cwd();
let pkg = {};
@ -19,6 +22,12 @@ try {
const pkgPresets = pathOr([], ['neutrino', 'presets'], pkg);
const environments = { build: 'production', start: 'development', test: 'test' };
const args = yargs
.option('inspect', {
description: 'Output a string representation of the configuration used by Neutrino and exit',
boolean: true,
default: false,
global: true
})
.option('presets', {
description: 'A list of Neutrino presets used to configure the build',
array: true,
@ -84,6 +93,10 @@ function run(command, presets) {
api.config.merge(pkg.neutrino.config);
}
if (args.inspect) {
return inspect(api.getWebpackOptions());
}
api[command](args)
.then(() => process.exit(0))
.catch(err => {

4
packages/neutrino/package.json

@ -22,10 +22,12 @@
"test": "ava test"
},
"dependencies": {
"deep-sort-object": "^1.0.1",
"javascript-stringify": "^1.6.0",
"ora": "^1.1.0",
"ramda": "^0.23.0",
"webpack": "^2.2.1",
"webpack-chain": "^1.4.2",
"webpack-chain": "^2.0.0",
"webpack-dev-server": "^2.4.1",
"yargs": "^6.6.0"
}

3
packages/neutrino/test/api_test.js

@ -96,9 +96,6 @@ test('creates a Webpack config', t => {
});
t.deepEqual(api.getWebpackOptions(), {
resolve: { modules: [], extensions: [] },
resolveLoader: { modules: [] },
plugins: [],
module: {
rules: [
{

26
packages/neutrino/yarn.lock

@ -513,6 +513,12 @@ deep-extend@~0.4.0:
version "0.4.1"
resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.4.1.tgz#efe4113d08085f4e6f9687759810f807469e2253"
deep-sort-object@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/deep-sort-object/-/deep-sort-object-1.0.1.tgz#c42a479167d139aa2030dccda46d49ca8a736496"
dependencies:
is-plain-object "^2.0.1"
deepmerge@^1.3.2:
version "1.3.2"
resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-1.3.2.tgz#1663691629d4dbfe364fa12a2a4f0aa86aa3a050"
@ -1072,6 +1078,12 @@ is-number@^2.0.2, is-number@^2.1.0:
dependencies:
kind-of "^3.0.2"
is-plain-object@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.1.tgz#4d7ca539bc9db9b737b8acb612f2318ef92f294f"
dependencies:
isobject "^1.0.0"
is-posix-bracket@^0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz#3334dc79774368e92f016e6fbc0a88f5cd6e6bc4"
@ -1096,6 +1108,10 @@ isarray@1.0.0, isarray@^1.0.0, isarray@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"
isobject@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/isobject/-/isobject-1.0.2.tgz#f0f9b8ce92dd540fa0740882e3835a2e022ec78a"
isobject@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89"
@ -1106,6 +1122,10 @@ isstream@~0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a"
javascript-stringify@^1.6.0:
version "1.6.0"
resolved "https://registry.yarnpkg.com/javascript-stringify/-/javascript-stringify-1.6.0.tgz#142d111f3a6e3dae8f4a9afd77d45855b5a9cce3"
jodid25519@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/jodid25519/-/jodid25519-1.0.2.tgz#06d4912255093419477d425633606e0e90782967"
@ -2137,9 +2157,9 @@ wbuf@^1.1.0, wbuf@^1.4.0:
dependencies:
minimalistic-assert "^1.0.0"
webpack-chain@^1.4.2:
version "1.4.2"
resolved "https://registry.yarnpkg.com/webpack-chain/-/webpack-chain-1.4.2.tgz#b420d68c1e395fbe8167a26e133844a2d4efb2ed"
webpack-chain@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/webpack-chain/-/webpack-chain-2.0.0.tgz#ddf52623b110e552684cec7e85f97b24a7b57f10"
dependencies:
deepmerge "^1.3.2"

Loading…
Cancel
Save