Creating a modern Node.js app with Backpack can be as easy as implementing the following steps:
- Install Backpack via npm:
$ npm i backpack-core
- Create a /src/ directory and a package.json file in the project root with backpack in the dev script as follows:
{
"scripts": {
"dev": "backpack"
}
}
Note that you must provide the /src/ as the default entry directory of your app.
- Create a Backpack config file in your project root with a function to configure webpack as follows:
// backpack.config.js
module.exports = {
webpack: (config, options, webpack) => {
// ....
return config
}
}
This step is optional, but it is useful if you want to change the default entry directory (which is the /src/ directory that you created in step 2) of your app to a different one, for example, a /server/ directory, this can be done as follows:
webpack: (config, options, webpack) => {
config...