- Express Setup
- Webpack installation
- Plugins installation
- Loaders (and dependencies) installation
- NOTES
express --pug
npm install
npm install --save-dev webpack webpack-cli
npm install --save-dev \
html-webpack-plugin \
clean-webpack-plugin \
;
npm install --save-dev \
style-loader \
css-loader \
sass-loader \
node-sass \
;
npm install --save-dev pug-loader;
npm install --save-dev file-loader;
npm install --save-dev webpack-node-externals;
- This will avoid to pack node_modules.
npm install --save-dev \
@babel/core \
babel-loader \
@babel/preset-env \
@babel/polyfill \
;
npm install --save-dev null-loader;
npm install --save-dev jquery
Unix* shebang is not supported so first row in 'bin/www'
(#!/usr/bin/env node
must be removed).
When packing server:
-
Don't trust
__dirname
and__filename
__dirname
always resolves to "/".- ...so
__filename
is also relative to "/".
-
Keep in mind that relative paths will be based on the path from which the bundle got called.
You can obtain bundle file path with process.argv[1]
.
Example:
const path = require("path");
const basePath = path.dirname(process.argv[1]));