Eli Perelman
8 years ago
43 changed files with 5870 additions and 235 deletions
@ -1,8 +1,12 @@ |
|||||
const { BannerPlugin } = require('webpack'); |
const { BannerPlugin } = require('webpack'); |
||||
const merge = require('deepmerge'); |
const merge = require('deepmerge'); |
||||
|
|
||||
module.exports = ({ config }, options) => config.plugin('banner', BannerPlugin, merge({ |
module.exports = ({ config }, options) => config |
||||
banner: `require('source-map-support').install();`, |
.plugin('banner') |
||||
raw: true, |
.use(BannerPlugin, [ |
||||
entryOnly: true |
merge({ |
||||
}, options)); |
banner: `require('source-map-support').install();`, |
||||
|
raw: true, |
||||
|
entryOnly: true |
||||
|
}, options) |
||||
|
]); |
||||
|
@ -1,7 +1,8 @@ |
|||||
const { CommonsChunkPlugin } = require('webpack').optimize; |
const { CommonsChunkPlugin } = require('webpack').optimize; |
||||
const merge = require('deepmerge'); |
const merge = require('deepmerge'); |
||||
|
|
||||
module.exports = ({ config }, options) => config.plugin('chunk', CommonsChunkPlugin, merge({ |
module.exports = ({ config }, options) => config |
||||
minChunks: Infinity, |
.plugin('chunk') |
||||
names: ['vendor', 'manifest'] |
.use(CommonsChunkPlugin, [ |
||||
}, options)); |
merge({ minChunks: Infinity, names: ['vendor', 'manifest'] }, options) |
||||
|
]); |
||||
|
@ -1,5 +1,17 @@ |
|||||
module.exports = ({ config }, options) => config.module |
module.exports = ({ config }, options) => { |
||||
.rule('compile') |
const rule = config.module |
||||
.test(/\.jsx?$/) |
.rule('compile') |
||||
.include(...options.include) |
.test(options.test || /\.jsx?$/) |
||||
.loader('babel', require.resolve('babel-loader'), options.babel); |
.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 CopyPlugin = require('copy-webpack-plugin'); |
||||
const merge = require('deepmerge'); |
const merge = require('deepmerge'); |
||||
|
|
||||
module.exports = ({ config }, options) => { |
module.exports = ({ config }, opts) => { |
||||
const opts = merge({ patterns: [], options: {} }, options); |
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'); |
const { EnvironmentPlugin } = require('webpack'); |
||||
|
|
||||
module.exports = ({ config }, envs = []) => config.plugin('env', EnvironmentPlugin, |
module.exports = ({ config }, envs = []) => config |
||||
['NODE_ENV', ...(Array.isArray(envs) ? envs : [])]); |
.plugin('env') |
||||
|
.use(EnvironmentPlugin, ['NODE_ENV', ...(Array.isArray(envs) ? envs : [])]); |
||||
|
@ -1,3 +1,3 @@ |
|||||
const { HotModuleReplacementPlugin } = require('webpack'); |
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 |
module.exports = ({ config }) => config.module |
||||
.rule('html') |
.rule('html') |
||||
.test(/\.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'); |
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'); |
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'); |
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'); |
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 |
module.exports = ({ config }) => config.module |
||||
.rule('style') |
.rule('style') |
||||
.test(/\.css$/) |
.test(/\.css$/) |
||||
.loader('style', require.resolve('style-loader')) |
.use('style').loader(require.resolve('style-loader')).end() |
||||
.loader('css', require.resolve('css-loader')); |
.use('css').loader(require.resolve('css-loader')); |
||||
|
@ -1,28 +1,35 @@ |
|||||
const lint = require('neutrino-middleware-eslint'); |
const lint = require('neutrino-middleware-eslint'); |
||||
const merge = require('deepmerge'); |
const merge = require('deepmerge'); |
||||
const { join } = require('path'); |
|
||||
|
|
||||
module.exports = (neutrino, options) => neutrino.use(lint, merge({ |
module.exports = (neutrino, options) => { |
||||
include: options.include ? [] : [join(process.cwd(), 'SRC')], |
neutrino.use(lint, merge({ |
||||
eslint: { |
eslint: { |
||||
baseConfig: { |
baseConfig: { |
||||
extends: ['airbnb-base'] |
extends: ['airbnb-base'] |
||||
}, |
}, |
||||
rules: { |
rules: { |
||||
// handled by babel rules
|
// handled by babel rules
|
||||
'new-cap': 'off', |
'new-cap': 'off', |
||||
|
|
||||
// handled by babel rules
|
// handled by babel rules
|
||||
'object-curly-spacing': 'off', |
'object-curly-spacing': 'off', |
||||
|
|
||||
// require a capital letter for constructors
|
// require a capital letter for constructors
|
||||
'babel/new-cap': ['error', { newIsCap: true }], |
'babel/new-cap': ['error', { newIsCap: true }], |
||||
|
|
||||
// require padding inside curly braces
|
// require padding inside curly braces
|
||||
'babel/object-curly-spacing': ['error', 'always'], |
'babel/object-curly-spacing': ['error', 'always'], |
||||
|
|
||||
// guard against awaiting async functions inside of a loop
|
// guard against awaiting async functions inside of a loop
|
||||
'babel/no-await-in-loop': 'error' |
'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