@nitro/webpack
nitro webpack
Last updated 3 days ago by ernscht .
MIT · Original npm · Tarball · package.json
$ cnpm install @nitro/webpack 
SYNC missed versions from official npm registry.

npm version License Build Status

Nitro Webpack

Configurable and easy to use webpack 4 config for nitro projects.

Usage

const options = {
    rules: {
        js: {
            eslint: false,
        },
        ts: false,
        scss: {
            stylelint: false,
        },
        hbs: true,
        woff: true,
        font: false,
        image: true,
    },
    features: {
        banner: true,
        bundleAnalyzer: false,
        theme: false,
        dynamicAlias: false,
    },
};
const webpackConfig = require('@nitro/webpack/webpack-config/webpack.config.dev')(options);

module.exports = webpackConfig;

Configuration

Rules

No loader rule is enabled by default. Activate following prepared rules you need in options.rules

options.rules.js

  • Type: boolean || object
  • default: false
  • file types: js, jsx, mjs

Config:

  • true or {} activates JavaScript support
  • { eslint: true } additionally adds eslint live linting feature (only relevant for development build)

options.rules.ts

  • Type: boolean
  • default: false
  • file types: ts, tsx

Config:

  • true will activate TypeScript support

options.rules.scss

  • Type: boolean || object
  • default: false
  • file types: scss, css

Config:

  • true or {} will activate scss support
  • { stylelint: true } additionally adds stylelint live linting feature (only relevant for development build)

options.rules.hbs

  • Type: boolean || object
  • default: false
  • file types: hbs

Config:

  • true or {} will activate handlebars handlebars precompiled templates support
  • { include: [] } additionally adds include config to rule
  • { exclude: [] } additionally adds exclude config to rule

options.rules.woff

  • Type: boolean || object
  • default: false
  • file types: woff, woff2

Config:

  • true or {} will activate woff font support (in CSS files)
  • { include: [] } additionally adds include config to rule
  • { exclude: [] } additionally adds exclude config to rule

options.rules.font

  • type: boolean || object
  • default: false
  • file types: eot, svg, ttf, woff, woff2

Config:

  • true or {} will activate font support for eot, svg, ttf, woff & woff2 fonts (in CSS files)
  • { include: [] } additionally adds include config to rule
  • { exclude: [] } additionally adds exclude config to rule

⚠ Please use this rule with care. You have to configure includes and exclude when you also use woff and/or image loader. Otherwise svg or woff files are processed with multiple configurations.

options.rules.image

  • Type: boolean || object
  • default: false
  • file types: png, jpg, gif, svg

Config:

  • true will activate image support
  • { include: [] } additionally adds include config to rule
  • { exclude: [] } additionally adds exclude config to rule

options.features

Enable some additional features

options.features.banner

  • Type: boolean
  • default: true

(only relevant for production build)

true will add a text banner with infos from package.json to the bundled js & css

options.features.bundleAnalyzer

  • Type: boolean
  • default: false

true will add the bundleAnalyser plugin and opens a browser window with the stats

options.features.theme

  • Type: string || false
  • default: false

A string will activate theming support:

  • webpack uses ./src/ui.${theme} as entrypoint (instead of ./src/ui)
  • a subfolder within assets is used for the output path and publicPath (/assets/${theme}/)

It makes sense to use a dynamic value e.g. an environment variable, as shown in the example configuration.

options.features.dynamicAlias

  • Type: object || false
  • default: false

A proper configured dynamicAlias feature will activate the DynamicAliasResolverPlugin which can change import paths in source files dynamically on compile time as desired.

Properties:

  • options.features.dynamicAlias.search (string || RegExp) search term to be replaced (e.g. '/theme/light')
  • options.features.dynamicAlias.replace (string) string as replacement (e.g. /theme/${theme})

Extending Configuration

Code Splitting

By default, all js imports from 'node_modules' are extracted to a 'vendors.js' to use in your view files.

Dynamically imported js files will be extracted to public/js/dynamic/. You may use them in a promise chain.

import('package-name').then((pack) => {
	// do something with 'pack'
});

import(/* webpackChunkName: "mychunk" */ 'package-name').then((pack) => {
	// do something with 'pack'
});

You may change the default configuration in webpackConfig.optimization.splitChunks

Changelog

Recent changes can be viewed on Github on the Releases Page

Current Tags

  • 5.3.0                                ...           latest (3 days ago)
  • 5.0.0-rc.2                                ...           next (6 months ago)

99 Versions

  • 5.3.0                                ...           3 days ago
  • 5.2.9                                ...           9 days ago
  • 5.2.8                                ...           20 days ago
  • 5.2.7                                ...           a month ago
  • 5.2.6                                ...           a month ago
  • 5.2.5                                ...           2 months ago
  • 5.2.4                                ...           2 months ago
  • 5.2.3                                ...           2 months ago
  • 5.2.2                                ...           3 months ago
  • 5.2.1                                ...           3 months ago
  • 5.2.0                                ...           4 months ago
  • 5.1.6                                ...           4 months ago
  • 5.1.5                                ...           4 months ago
  • 5.1.4                                ...           5 months ago
  • 5.1.3                                ...           5 months ago
  • 5.1.2                                ...           5 months ago
  • 5.1.1                                ...           5 months ago
  • 5.1.0                                ...           6 months ago
  • 5.0.1                                ...           6 months ago
  • 5.0.0                                ...           6 months ago
  • 4.14.4                                ...           6 months ago
  • 5.0.0-rc.2                                ...           6 months ago
  • 5.0.0-rc.1                                ...           6 months ago
  • 5.0.0-beta                                ...           7 months ago
  • 4.14.3                                ...           7 months ago
  • 4.14.2                                ...           7 months ago
  • 4.14.1                                ...           7 months ago
  • 4.14.0                                ...           7 months ago
  • 4.13.5                                ...           7 months ago
  • 4.13.4                                ...           8 months ago
  • 4.13.3                                ...           8 months ago
  • 4.13.2                                ...           8 months ago
  • 4.13.1                                ...           8 months ago
  • 4.13.0                                ...           8 months ago
  • 4.12.0                                ...           9 months ago
  • 4.11.0                                ...           9 months ago
  • 4.10.0                                ...           9 months ago
  • 4.9.0                                ...           9 months ago
  • 4.8.3                                ...           10 months ago
  • 4.8.2                                ...           10 months ago
  • 4.8.1                                ...           10 months ago
  • 4.8.0                                ...           a year ago
  • 4.7.5                                ...           a year ago
  • 4.7.4                                ...           a year ago
  • 4.7.3                                ...           a year ago
  • 4.7.2                                ...           a year ago
  • 4.7.1                                ...           a year ago
  • 4.7.0                                ...           a year ago
  • 4.6.6                                ...           a year ago
  • 4.6.5                                ...           a year ago
  • 4.6.4                                ...           a year ago
  • 4.6.3                                ...           a year ago
  • 4.6.2                                ...           a year ago
  • 4.6.1                                ...           a year ago
  • 4.6.0                                ...           a year ago
  • 4.5.2                                ...           a year ago
  • 4.5.1                                ...           a year ago
  • 4.5.0                                ...           a year ago
  • 4.4.4                                ...           a year ago
  • 4.4.3                                ...           a year ago
  • 4.4.2                                ...           a year ago
  • 4.4.1                                ...           a year ago
  • 4.4.0                                ...           a year ago
  • 4.3.6                                ...           a year ago
  • 4.3.5                                ...           a year ago
  • 4.3.4                                ...           a year ago
  • 4.3.3                                ...           a year ago
  • 4.3.2                                ...           a year ago
  • 4.3.1                                ...           a year ago
  • 4.3.0                                ...           a year ago
  • 4.2.3                                ...           a year ago
  • 4.2.2                                ...           a year ago
  • 4.2.1                                ...           a year ago
  • 4.2.0                                ...           a year ago
  • 4.1.9                                ...           a year ago
  • 4.1.8                                ...           a year ago
  • 4.1.7                                ...           2 years ago
  • 4.1.6                                ...           2 years ago
  • 4.1.5                                ...           2 years ago
  • 4.1.4                                ...           2 years ago
  • 4.1.3                                ...           2 years ago
  • 0.5.2                                ...           2 years ago
  • 0.5.1                                ...           2 years ago
  • 0.5.0                                ...           2 years ago
  • 0.4.0                                ...           2 years ago
  • 0.3.11                                ...           2 years ago
  • 0.3.10                                ...           2 years ago
  • 0.3.9                                ...           2 years ago
  • 0.3.8                                ...           2 years ago
  • 0.3.7                                ...           2 years ago
  • 0.3.6                                ...           2 years ago
  • 0.3.5                                ...           2 years ago
  • 0.3.4                                ...           2 years ago
  • 0.3.3                                ...           2 years ago
  • 0.3.2                                ...           2 years ago
  • 0.3.1                                ...           2 years ago
  • 0.3.0                                ...           2 years ago
  • 0.2.0                                ...           2 years ago
  • 0.1.0                                ...           2 years ago

Copyright 2014 - 2016 © taobao.org |