1 | [tests]: https://img.shields.io/circleci/project/github/shellscape/webpack-nano.svg
|
2 | [tests-url]: https://circleci.com/gh/shellscape/webpack-nano
|
3 |
|
4 | [cover]: https://codecov.io/gh/shellscape/webpack-nano/branch/master/graph/badge.svg
|
5 | [cover-url]: https://codecov.io/gh/shellscape/webpack-nano
|
6 |
|
7 | [size]: https://packagephobia.now.sh/badge?p=webpack-nano
|
8 | [size-url]: https://packagephobia.now.sh/result?p=webpack-nano
|
9 |
|
10 | <div align="center">
|
11 | <img width="256" src="https://raw.githubusercontent.com/shellscape/webpack-nano/master/assets/nano.svg?sanitize=true" alt="webpack-nano"><br/><br/>
|
12 | </div>
|
13 |
|
14 | # webpack-nano [![tests][tests]][tests-url] [![cover][cover]][cover-url] [![size][size]][size-url]
|
15 |
|
16 | A teensy, squeaky 🐤 clean Webpack CLI
|
17 |
|
18 | `webpack-nano` operates on the premise that all options for configuring a webpack build are set via a [config file](https://webpack.js.org/configuration/).
|
19 |
|
20 | ## Install
|
21 |
|
22 | Using npm:
|
23 |
|
24 | ```console
|
25 | npm install webpack-nano --save-dev
|
26 | ```
|
27 |
|
28 | <a href="https://www.patreon.com/shellscape">
|
29 | <img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" width="160">
|
30 | </a>
|
31 |
|
32 | ## Requirements
|
33 |
|
34 | `webpack-nano` is an evergreen module. 🌲 This module requires an [Active LTS](https://github.com/nodejs/Release) Node version (v8.0.0+ or v10.0.0+).
|
35 |
|
36 | ## Benefits
|
37 |
|
38 | - Holy bananas 🍌 it's itsy bitsy
|
39 | - Doesn't hit you over the head with an avalanche of flags and options
|
40 | - Allows any number of user-defined flags
|
41 | - It does one thing: tells webpack to start a build
|
42 | - ~90% smaller than webpack-cli and webpack-command
|
43 |
|
44 | ## Usage
|
45 |
|
46 | ```console
|
47 | $ npx wp --help
|
48 |
|
49 | Usage
|
50 | $ wp [...options]
|
51 |
|
52 | Options
|
53 | --config A path to a webpack config file
|
54 | --config.{name} A path to a webpack config file, and the config name to run
|
55 | --help Displays this message
|
56 | --silent Instruct the CLI to produce no console output
|
57 | --version Displays webpack-nano and webpack versions
|
58 |
|
59 | Examples
|
60 | $ wp
|
61 | $ wp --help
|
62 | $ wp --config webpack.config.js
|
63 | $ wp --config.serve webpack.config.js
|
64 | ```
|
65 |
|
66 | ## Custom Flags
|
67 |
|
68 | With `webpack-cli` users are limited as to the flags they can use on with the `$ webpack` binary, and are instructed to use the `--env` flag for custom data. Well that's just 🍌🍌. With `webpack-nano` users can specify an unlimited number of custom flags, _without restriction_.
|
69 |
|
70 | Say you have a bundle which can be built to use different asset locations from cloud data sources, like Amazon S3 or Google Cloud Storage. And in this scenario you prefer to specify that location using a command-line flag. If you were using `webpack-cli`, you'd have to use the `--env.source` flag (or you'd get a big 'ol error) and use a function for your `webpack.config.js` export. Using `webpack-nano`:
|
71 |
|
72 | ```console
|
73 | $ wp --config webpack.config.js --source s3
|
74 | ```
|
75 |
|
76 | ```js
|
77 | // webpack.config.js
|
78 | const argv = require('webpack-nano/argv');
|
79 |
|
80 | const { source } = argv;
|
81 |
|
82 | module.exports = {
|
83 | ...
|
84 | }
|
85 | ```
|
86 |
|
87 | ✨ Magic. The `webpack-nano/argv` export provides quick and easy access to parsed command-line arguments, allowing the user to define the CLI experience as they want to.
|
88 |
|
89 | ## Special Configuration File Types
|
90 |
|
91 | Webpack configuration files can be written using a variety of module loaders. e.g. Babel or TypeScript. `webpack-nano` allows users to use file types like `webpack.config.babel.js`, `webpack.config.es6`, `webpack.config.mjs`, and `webpack.config.ts`. Users are responsible for installing a compatible module loader when using these special file types. The table below represents the supported file types and their compatible loaders:
|
92 |
|
93 | | Extension | Compatible Loaders |
|
94 | | ------------| ------------------ |
|
95 | | `.babel.js` | `@babel/register`, `babel-register`, `babel-core/register`, `babel/register` |
|
96 | | `.babel.ts` | `@babel/register` |
|
97 | | `.es6` | `@babel/register` |
|
98 | | `.mjs` | `@babel/register` |
|
99 | | `.ts` | `ts-node/register`, `typescript-node/register`, `typescript-register`, `typescript-require` |
|
100 |
|
101 | ## Build Stats
|
102 |
|
103 | This project attempts not to make assumptions about how a build should behave, and that includes webpack [`stats`](https://webpack.js.org/configuration/stats/). By default, `webpack-nano` will apply two `stats` options: `colors` (based on [`supports-color`](https://github.com/chalk/supports-color) and `exclude: ['node_modules']`). These can be quickly overridden by including these key/values in your stats configuration.
|
104 |
|
105 | ## Meta
|
106 |
|
107 | [CONTRIBUTING](./.github/CONTRIBUTING.md)
|
108 |
|
109 | [LICENSE (Mozilla Public License)](./LICENSE)
|