This is an application derived from Sean Larkin's Front End Masters course on Webpack 4. Using the tools from his presentation I was able to create a good workflow for React Application using Web Pack.
This project assumes you have NodeJS v8 or greater installed. You should also have npm v5 or greater installed as well (this comes packaged with Node 8). You'll also need a recent version of git installed as well.
To get started with the project, start with this:
- Sign up for a GitHub Account (if you don't already have one)
- Fork this repo
- Clone your fork
- In the directory you cloned the repository, run git fetch --all
- Install Node JS.
- [cd] into the root of the project directory.
- Run npm install on the terminal to install Dependecies
webpack.config.js
module.exports = ({ mode, presets } = { mode: "production", presets: [] }) =>
webPackMerge(
{
mode,
plugins: [htmlPlugin, webPack],
},
modeConfig(mode),
loadPresets({ mode, presets })
);
Name | Type | Description |
---|---|---|
mode |
{String} |
Default set to production |
plugins |
[Array] |
HtmlPlugin installed by default to bundle.This is a webpack plugin that simplifies creation of HTML files to serve your webpack bundles |
modeConfig |
{function} |
Config information for the environment specified is generated here |
loadPresets |
{function} |
Config information for the presets |
Current state of webpack has been optimized for react applications but the environments can be refactored depending on usage.
- cd into the build-utils
- Make a webpack config file
- Edit the package.json scripts to run the presets. Remember to add a mode.
Example
cd build-utils/presets
touch webpack.compress.js
const CompressionWebpackPlugin = require("compression-webpack-plugin");
module.exports = () => ({
plugins: [new CompressionWebpackPlugin()]
});
- In the package.json scripts
"prod:compress": "npm run prod -- --env.presets compress",
to run the compression presets with your production configz
For more details contact benny.ogidan@andela.com
For any suggestions or contributions please do not hesistate to contact me
Contributions to this project are welcomed by all, If you need to contribute to this project, follow the steps below
- Fork the repository
- Follow Installation and Setup as explained earlier
- Create a branch off develop for the feature you wish to add
- Make neccessary changes, commit and raise a pull request against develop, conventions can be found on the wiki page Note when making contributions, please endevour to follow the Airbnb javascript style guide.
This project is authored by Benny Ogidan (benny.ogidan@andela.com) and is licensed for your use, modification and distribution under the MIT license. MIT © benny-ogidan