Webpack Ignite
Table of Contents
- Environment Setup
- Configuration
- Start Developing
- Production Build Directions
- Future!
1. Environment Setup
Install Webpack Ignite globally (npm install -g webpack-ignite)
Create a new webpack projects
* run `wpignite ignite <project_folder>`
Install NPM Packages
- Run
yarn install
or npm install
from the console in the folder that was just created. - Edit the
package.json
to have the correct information.
2. Configuration
Config files
Most of the configuration files are in the .ignite
folder. The project defaults are generally pretty good but can be edited / overridden by editing overrides.js
and editing the values contained in that file:
const basicConfigOverrides = {
srcPath: 'src',
outputPath: 'build',
contentPath: 'src',
templatePath: 'src',
usejQuery: true,
usePreact: false,
useStandaloneVue: false,
useHashInProd: true,
minifyHTMLInProd: false,
cleanBeforeBuild: true,
inlineAssetMaxSize: 20000,
hotOnlyDevServer: false,
devServerHost: "localhost",
devServerAllowExternalAccess: false,
autoOpenBrowser: true,
}
const advancedConfigOverrides = {
publicPath: '/',
cssRelativePath: '../',
fileLoaderRelativePath: '../',
urlLoaderExclusions: [
/\.html$/,
/\.(js|jsx|vue)(\?.*)?$/,
/\.css$/,
/\.scss$/,
/\.json$/,
/\.ejs$/,
],
fileLoaderFiles: [],
babelFiles: [/\.(js|jsx)$/],
babelExcludes: [],
devSourceMapMode: 'eval',
externals:{},
cssPreProcessingExcludes: [],
postCssOptions: {
data: '@import "global";',
includePaths: [
path.join(__appDir, '..', 'src/assets/scss/'),
path.join(__appDir, '..', 'node_modules/foundation-sites/scss')
]
}
}
3. Start Developing!!
Setup Entry Pages / Templates
- Edit the
.ignite/entries.js
file to contain the pages you need to create. Follow the directions contained in that file.
Setup JS /EJS Files for each entry
- Each entry in the entties.js file will need a .js file and a .ejs file configured per the
.ignite/entries.js
to work properly.
Start webpack
npm run start
- Webpack dev server will pick a port (starting at 3000) and launch a browser (if configured to do so).
Build a website!
- Use EJS, Sass, and ES6 and go to town!
4. Production Build Directions
For a production build run npm run build
. The results of the build will be in the build
folder and can be zipped and deployed to a server.
5. More stuff coming in the future
I have more plans for this in the future. You should be able to take advantage of any improvements to the build process by simply upgrading webpack-ignite in your project! (This will require that you don't edit the webpack.config to remove certain functionality)
- Best practice tuning for webpack output
- More concise settings
- Better build / asset copy methods
- Automated Testing
- Multiple / Configurable Templates
- React / Vue Examples