webpack-config-spaceship v0.8.1
webpack-config-spaceship
Webpack config to get a project off the ground fast.
Installation
npm install --save-dev webpack-config-spaceship
Setup
// webpack.config.js
const spaceship = require('webpack-config-spaceship');
module.exports = spaceship({
cwd: __dirname, // recommended
entry: {
main: './src/main/client/index.js',
},
output: {
path: './dist',
publicPath: '/assets',
},
});
Options
cwd
Path to project root.
{
cwd: __dirname, // recommended
}
context
Relative path to source directory. Affects entry paths. Relative to options.cwd
.
entry
Webpack entry.
{
main: './main/client/index.jsx'
}
https://webpack.js.org/configuration/entry-context/#entry
output.path
Relative path to output directory.
{
output: {
path: './build', // default
},
}
output.publicPath
https://webpack.js.org/guides/public-path
merge
Webpack config to be lodash.merge
d with the config generated by spaceship.
const config = spaceship({
merge: {
devServer: {
hot: true,
},
// etc
},
});
vendor
Boolean whether to automatically create a vendor chunk with babel-polyfill
and whatwg-fetch
. Turn this off for libraries.
common
Boolean whether to automatically create a common chunk. Turn this off for libraries.
filterPlugin(plugin, i)
A function to filter out plugins generated by spaceship.
const config = spaceship({
filterPlugin(plugin, i) {
if (Math.random() > 0.5) {
return false;
}
return true;
},
});
mapPlugin(plugin, i)
A function to replace some plugins with different ones.
const config = spaceship({
mapRule(rule, i) {
if (i === 0) {
return new webpack.optimize.OccurrenceOrderPlugin();
}
return rule;
},
});
filterRule(rule, i)
Same as filterPlugin
, but for rules.
mapRule(rule, i)
Same as mapPlugin
, but for rules.
statsPath
Path to save webpack stats.
{
statsPath: 'src/webpack.stats.json', // default
}
manifestPath
Path to save manifest file (list of files by entry and type).
{
manifestPath: 'src/webpack.manifest.json', // default
}
stylesheets
Disable ExtractTextPlugin.
Hot Module Reloading
Spaceship automatically configures:
HotModuleReplacementPlugin
NamedModulesPlugin
react-hot-loader/babel
devServer
config option
What you'll need to configure:
- entry loaders
react-hot-loader/patch
webpack-dev-server/client?http://localhost:8080
,webpack/hot/only-dev-server
<AppContainer />
https://webpack.js.org/guides/hmr-react/
License
Copyright (c) 2017 Marius Craciunoiu. Licensed under the MIT license.