
Build tool with zero initial configuration
Just use
npm i @dvhb/cli -g
mkdir my-app && cd my-app
dvhb init
You can change settings in the dvhb.config.js file in your project’s root folder.
titleType: String, default: Dvhb Webpack Starter kit
Title for index.html.
sourceDirType: String, default: src
Folder for source code.
distDirType: String, default: dist
The output directory.
publicPathType: String, default: /
Public path for assets.
viewsDirType: String, default: src/views
Folder for pug templates.
staticSiteType: Boolean, default: false
Enable static site mode with express server.
assetsDirType: String or Array, optional
Your application static assets folder, will be accessible as / in the dev-server or prod-server.
serverHostType: String, default: localhost
Development server host name.
serverPortType: Number, default: 3000
Dev server port.
eslintrcType: String, default: .eslintrc
Use ESLint config https://github.com/dvhb/eslint-config.
You can use your own eslint config if exists <project_dir>/.eslintrc
modernizrrcType: String, default: src/.modernizrrc
Use modernizer in application.
templateVarsType: Object, default: {}
Template global vars, useful for google analitics and other specific data.
spaType: String, default: false
Use spa routing with html5mode.
extendEntriesType: Object, optional
Extend app entries. Example for src/extEntry.js:
module.exports = {
// ...
extendEntries: {
extEntry: 'extEntry'
},
};
extendWebpackConfigType: Function, optional
Function that allows you to extend Webpack config:
module.exports = {
const merge = require('webpack-merge');
const path = require('path');
// ...
/**
* Extend webpack configuration
*
* @param webpackConfig {Object} – webpack config
* @param env {String} – environment
*/
extendWebpackConfig(webpackConfig, env) {
const dir = path.resolve(__dirname, 'src');
// @see https://webpack.js.org/configuration/
const commonConfig = merge(webpackConfig, {
module: {
rules: [
{
test: /\.<extention>?$/,
include: dir,
loader: '<loader>',
}
],
},
plugins: []
});
const productionConfig = merge({});
const developmentConfig = merge({});
return (env === 'production')? merge(commonConfig, productionConfig) : merge(commonConfig, developmentConfig);
}
};
configureServerType: Function, optional
Function that allows you to add endpoints to the underlying express server:
module.exports = {
// ...
/**
* Extend express server behavior
*
* @param app – instance of the express server
* @param env {String} – environment
*/
configureServer(app, env) {
app.get('/custom-endpoint', (req, res) => {
res.status(200).send({ response: 'Server invoked' });
});
// use items variable in templates
app.locals.items = require('./src/items.json');
},
};
dvhb initInit new project.
dvhb serverRun dev/prod server.
dvhb buildGenerate a dist bundle for project.
--config <file>Specify path to the config file.
--verbosePrint debug information.
--portServer port, default: 3000.
--envEnvironment, default: development.
--app-envApplication environment, experimental option.
ASSET_PATH="https://mysite.com/folder/"Specify webpack publicPath. See publicPath docs