Eli Perelman
8 years ago
43 changed files with 5870 additions and 235 deletions
@ -1,8 +1,12 @@ |
|||
const { BannerPlugin } = require('webpack'); |
|||
const merge = require('deepmerge'); |
|||
|
|||
module.exports = ({ config }, options) => config.plugin('banner', BannerPlugin, merge({ |
|||
banner: `require('source-map-support').install();`, |
|||
raw: true, |
|||
entryOnly: true |
|||
}, options)); |
|||
module.exports = ({ config }, options) => config |
|||
.plugin('banner') |
|||
.use(BannerPlugin, [ |
|||
merge({ |
|||
banner: `require('source-map-support').install();`, |
|||
raw: true, |
|||
entryOnly: true |
|||
}, options) |
|||
]); |
|||
|
@ -1,7 +1,8 @@ |
|||
const { CommonsChunkPlugin } = require('webpack').optimize; |
|||
const merge = require('deepmerge'); |
|||
|
|||
module.exports = ({ config }, options) => config.plugin('chunk', CommonsChunkPlugin, merge({ |
|||
minChunks: Infinity, |
|||
names: ['vendor', 'manifest'] |
|||
}, options)); |
|||
module.exports = ({ config }, options) => config |
|||
.plugin('chunk') |
|||
.use(CommonsChunkPlugin, [ |
|||
merge({ minChunks: Infinity, names: ['vendor', 'manifest'] }, options) |
|||
]); |
|||
|
@ -1,5 +1,17 @@ |
|||
module.exports = ({ config }, options) => config.module |
|||
.rule('compile') |
|||
.test(/\.jsx?$/) |
|||
.include(...options.include) |
|||
.loader('babel', require.resolve('babel-loader'), options.babel); |
|||
module.exports = ({ config }, options) => { |
|||
const rule = config.module |
|||
.rule('compile') |
|||
.test(options.test || /\.jsx?$/) |
|||
.use('babel') |
|||
.loader(require.resolve('babel-loader')) |
|||
.options(options.babel) |
|||
.end(); |
|||
|
|||
if (options.include) { |
|||
rule.include.merge(options.include); |
|||
} |
|||
|
|||
if (options.exclude) { |
|||
rule.exclude.merge(options.exclude); |
|||
} |
|||
}; |
|||
|
File diff suppressed because it is too large
@ -1,8 +1,10 @@ |
|||
const CopyPlugin = require('copy-webpack-plugin'); |
|||
const merge = require('deepmerge'); |
|||
|
|||
module.exports = ({ config }, options) => { |
|||
const opts = merge({ patterns: [], options: {} }, options); |
|||
module.exports = ({ config }, opts) => { |
|||
const { patterns, options } = merge({ patterns: [], options: {} }, opts); |
|||
|
|||
config.plugin('copy', CopyPlugin, opts.patterns, opts.options); |
|||
config |
|||
.plugin('copy') |
|||
.use(CopyPlugin, [patterns, options]); |
|||
}; |
|||
|
@ -1,4 +1,5 @@ |
|||
const { EnvironmentPlugin } = require('webpack'); |
|||
|
|||
module.exports = ({ config }, envs = []) => config.plugin('env', EnvironmentPlugin, |
|||
['NODE_ENV', ...(Array.isArray(envs) ? envs : [])]); |
|||
module.exports = ({ config }, envs = []) => config |
|||
.plugin('env') |
|||
.use(EnvironmentPlugin, ['NODE_ENV', ...(Array.isArray(envs) ? envs : [])]); |
|||
|
@ -1,3 +1,3 @@ |
|||
const { HotModuleReplacementPlugin } = require('webpack'); |
|||
|
|||
module.exports = ({ config }) => config.plugin('hot', HotModuleReplacementPlugin); |
|||
module.exports = ({ config }) => config.plugin('hot').use(HotModuleReplacementPlugin); |
|||
|
@ -1,4 +1,6 @@ |
|||
module.exports = ({ config }) => config.module |
|||
.rule('html') |
|||
.test(/\.html$/) |
|||
.loader('file', require.resolve('file-loader'), { name: '[name].[ext]' }); |
|||
.use('file') |
|||
.loader(require.resolve('file-loader')) |
|||
.options({ name: '[name].[ext]' }); |
|||
|
File diff suppressed because it is too large
@ -1,3 +1,3 @@ |
|||
const BabiliPlugin = require('babili-webpack-plugin'); |
|||
|
|||
module.exports = ({ config }) => config.plugin('minify', BabiliPlugin); |
|||
module.exports = ({ config }) => config.plugin('minify').use(BabiliPlugin); |
|||
|
@ -1,3 +1,3 @@ |
|||
const { NamedModulesPlugin } = require('webpack'); |
|||
|
|||
module.exports = ({ config }) => config.plugin('named-modules', NamedModulesPlugin); |
|||
module.exports = ({ config }) => config.plugin('named-modules').use(NamedModulesPlugin); |
|||
|
@ -1,3 +1,3 @@ |
|||
const ProgressBarPlugin = require('progress-bar-webpack-plugin'); |
|||
|
|||
module.exports = ({ config }) => config.plugin('progress', ProgressBarPlugin); |
|||
module.exports = ({ config }) => config.plugin('progress').use(ProgressBarPlugin); |
|||
|
File diff suppressed because it is too large
@ -1,3 +1,3 @@ |
|||
const StartServerPlugin = require('start-server-webpack-plugin'); |
|||
|
|||
module.exports = ({ config }, options) => config.plugin('start-server', StartServerPlugin, options.name); |
|||
module.exports = ({ config }, options) => config.plugin('start-server').use(StartServerPlugin, [options.name]); |
|||
|
@ -1,5 +1,5 @@ |
|||
module.exports = ({ config }) => config.module |
|||
.rule('style') |
|||
.test(/\.css$/) |
|||
.loader('style', require.resolve('style-loader')) |
|||
.loader('css', require.resolve('css-loader')); |
|||
.use('style').loader(require.resolve('style-loader')).end() |
|||
.use('css').loader(require.resolve('css-loader')); |
|||
|
@ -1,28 +1,35 @@ |
|||
const lint = require('neutrino-middleware-eslint'); |
|||
const merge = require('deepmerge'); |
|||
const { join } = require('path'); |
|||
|
|||
module.exports = (neutrino, options) => neutrino.use(lint, merge({ |
|||
include: options.include ? [] : [join(process.cwd(), 'SRC')], |
|||
eslint: { |
|||
baseConfig: { |
|||
extends: ['airbnb-base'] |
|||
}, |
|||
rules: { |
|||
// handled by babel rules
|
|||
'new-cap': 'off', |
|||
module.exports = (neutrino, options) => { |
|||
neutrino.use(lint, merge({ |
|||
eslint: { |
|||
baseConfig: { |
|||
extends: ['airbnb-base'] |
|||
}, |
|||
rules: { |
|||
// handled by babel rules
|
|||
'new-cap': 'off', |
|||
|
|||
// handled by babel rules
|
|||
'object-curly-spacing': 'off', |
|||
// handled by babel rules
|
|||
'object-curly-spacing': 'off', |
|||
|
|||
// require a capital letter for constructors
|
|||
'babel/new-cap': ['error', { newIsCap: true }], |
|||
// require a capital letter for constructors
|
|||
'babel/new-cap': ['error', { newIsCap: true }], |
|||
|
|||
// require padding inside curly braces
|
|||
'babel/object-curly-spacing': ['error', 'always'], |
|||
// require padding inside curly braces
|
|||
'babel/object-curly-spacing': ['error', 'always'], |
|||
|
|||
// guard against awaiting async functions inside of a loop
|
|||
'babel/no-await-in-loop': 'error' |
|||
// guard against awaiting async functions inside of a loop
|
|||
'babel/no-await-in-loop': 'error' |
|||
} |
|||
} |
|||
}, options)); |
|||
|
|||
if (!options.include && !options.exclude) { |
|||
neutrino.config.module |
|||
.rule('lint') |
|||
.include |
|||
.add(neutrino.options.source); |
|||
} |
|||
}, options)); |
|||
}; |
|||
|
@ -0,0 +1,23 @@ |
|||
import test from 'ava'; |
|||
import { validate } from 'webpack'; |
|||
import Neutrino from 'neutrino'; |
|||
|
|||
test('loads preset', t => { |
|||
t.notThrows(() => require('..')); |
|||
}); |
|||
|
|||
test('uses preset', t => { |
|||
const api = new Neutrino(); |
|||
|
|||
t.notThrows(() => api.use(require('..'))); |
|||
}); |
|||
|
|||
test('valid preset', t => { |
|||
const api = new Neutrino(); |
|||
|
|||
api.use(require('..')); |
|||
|
|||
const errors = validate(api.getWebpackOptions()); |
|||
|
|||
t.is(errors.length, 0); |
|||
}); |
@ -0,0 +1,23 @@ |
|||
import test from 'ava'; |
|||
import { validate } from 'webpack'; |
|||
import Neutrino from 'neutrino'; |
|||
|
|||
test('loads preset', t => { |
|||
t.notThrows(() => require('..')); |
|||
}); |
|||
|
|||
test('uses preset', t => { |
|||
const api = new Neutrino(); |
|||
|
|||
t.notThrows(() => api.use(require('..'))); |
|||
}); |
|||
|
|||
test('valid preset', t => { |
|||
const api = new Neutrino(); |
|||
|
|||
api.use(require('..')); |
|||
|
|||
const errors = validate(api.getWebpackOptions()); |
|||
|
|||
t.is(errors.length, 0); |
|||
}); |
@ -0,0 +1,23 @@ |
|||
import test from 'ava'; |
|||
import { validate } from 'webpack'; |
|||
import Neutrino from 'neutrino'; |
|||
|
|||
test('loads preset', t => { |
|||
t.notThrows(() => require('..')); |
|||
}); |
|||
|
|||
test('uses preset', t => { |
|||
const api = new Neutrino(); |
|||
|
|||
t.notThrows(() => api.use(require('..'))); |
|||
}); |
|||
|
|||
test('valid preset', t => { |
|||
const api = new Neutrino(); |
|||
|
|||
api.use(require('..')); |
|||
|
|||
const errors = validate(api.getWebpackOptions()); |
|||
|
|||
t.is(errors.length, 0); |
|||
}); |
File diff suppressed because it is too large
Loading…
Reference in new issue