0.0.10 • Published 7 years ago

meyer-react-webpack-config v0.0.10

Weekly downloads
-
License
MIT
Repository
-
Last release
7 years ago

meyer-react-webpack-config

This here thing is a function that returns an opinionated webpack config. The function takes an object of options:

OptionDescription
componentPathpath to the root component. Required.
buildPathpath to webpack’s build destination. Required.
jsxstyleLoaderOptionsoptions object passed to jsxstyle-loader.
emitCallbackfunction that takes two parameters: the evaluated root component at componentPath and the compilation stats object. Expected to return an object of asset contents keyed by asset name.
htmlTemplatetemplate file used by html-webpack-plugin.
reactIDID of the DOM node that React mounts to. Defaults to .react-root.
cssFileNamename of the extracted CSS file. Defaults to bundle.css.
bundleFileNamename of the bundle generated by webpack. Defaults to bundle.js.
browsersarray of browsers supported by babel-preset-env and postcss-cssnext in browserslist format. Defaults to ['last 2 versions', '> 5%'].

how to use this thing

  1. Install it:

yarn add webpack webpack-dev-server meyer-react-webpack-config

  1. Create a webpack.config.js file that looks like this:

const path = require('path');

module.exports = require('meyer-react-webpack-config')({
  componentPath: require.resolve('./components/Site'),
  buildPath: path.resolve('build'),
});
  1. Add scripts to your package.json file:

  • For a producution build:

    webpack -p --progress

  • For a development hot-reloading environment:

    webpack-dev-server --hot --hotOnly --inline --historyApiFallback