Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexcambose/webpack-create-config
CLI tool for creating webpack config files
https://github.com/alexcambose/webpack-create-config
bundle cli config configuration create es6 generator loaders webpack webpack-dev-server webpack2
Last synced: about 2 months ago
JSON representation
CLI tool for creating webpack config files
- Host: GitHub
- URL: https://github.com/alexcambose/webpack-create-config
- Owner: alexcambose
- License: mit
- Created: 2017-09-30T17:58:47.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-10-08T08:22:31.000Z (over 7 years ago)
- Last Synced: 2024-11-15T01:40:02.494Z (3 months ago)
- Topics: bundle, cli, config, configuration, create, es6, generator, loaders, webpack, webpack-dev-server, webpack2
- Language: JavaScript
- Homepage:
- Size: 26.4 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# webpack-create-config
Command line tool for creating webpack config files
## Installation
You need to install `webpack-create-config` globally
```
$ npm i -g webpack-create-config
```
Now you can run CLI using following command anywhere
```
$ webpack-create-config
```
## Options
```
Usage: webpack-create-config [options]Options:
-V, --version output the version number
-e, --entry Entry point/points to build your project
-o, --output The output filename path
-c, --context [directory] The base directory
-d, --devtool [style] Enhance the debugging process by adding source maps
-l, --loaders [loaders] Add loaders
-s, --devserver Add webpack-dev-server
-w, --watch Watch files and recompile whenever they change
-a, --autoinstall Automatically install required dependencies
-h, --help output usage information
```
## Table of contents
* [Entry](#entry)
* [Output](#output)
* [Context](#context)
* [Devtool](#devtool)
* [Loaders](#loaders)
* [DevServer](#devserver)
* [Watch](#watch)
* [Autoinstall](#autoinstall)### Entry
[official docs](https://webpack.js.org/configuration/entry-context/#entry)`-e, --entry` **required**
Single file
```bash
$ webpack-create-config --entry ./src/index.js
```
```
$ webpack-create-config -e ./main.js
```
in `webpack.config.js`
```
entry: {
index: './src/index.js',
index2: './src/index2.js',
}
```
Multiple files
```
$ webpack-create-config --entry ./src/index.js,./src/index2.js
```
```
$ webpack-create-config -e ./src/index.js,./src/index2.js
```
`webpack.config.js`
```
entry: {
index: './src/index.js',
index2: './src/index2.js',
}
```### Output
[official docs](https://webpack.js.org/configuration/entry-context/#output)`-o, --output` **required**
```
$ webpack-create-config --output ./dist/bundle.js
```
```
$ webpack-create-config -o ./dist/bundle.js
```
in `webpack.config.js`
```
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, './dist'),
},
```
### Context
[official docs](https://webpack.js.org/configuration/entry-context/#context)`-c, --context` *optional*
```
$ webpack-create-config --context app
```
```
$ webpack-create-config -c app
```
in `webpack.config.js`
```
...
context: path.resolve(__dirname, 'app'),
...
```### Devtool
[official docs](https://webpack.js.org/configuration/devtool/#devtool)
`-d, --devtool` *optional*
```
$ webpack-create-config ... --devtool cheap-eval-source-map ...
```
```
$ webpack-create-config ... -d cheap-eval-source-map ...
```
in `webpack.config.js`
```
...
devtool: 'cheap-eval-source-map',
...
```### Loaders
[official docs](https://webpack.js.org/concepts/loaders/)`-d, --devtool` *optional*
```
$ webpack-create-config ... --loaders css,babel-es6 ...
```
```
$ webpack-create-config ... -l css,babel-es6 ...
```
in `webpack.config.js`
```
...
module: {
rules: [{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: ['es2015',],
},
},
},{
test: /\.css$/,
use: ['style-loader','css-loader',],
},],
},
...
```
List of avaliable loaders you can add using the CLI**css** - [css-loader](https://github.com/webpack-contrib/css-loader)
**less** - [less-loader](https://github.com/webpack-contrib/less-loader)
**sass** - [sass-loader](https://github.com/webpack-contrib/sass-loader)
**json** - [json-loader](https://github.com/webpack-contrib/json-loader)
**coffee** - [coffee-loader](https://github.com/webpack-contrib/coffee-loader)
**file** - [file-loader](https://github.com/webpack-contrib/file-loader)
**url** - [url-loader](https://github.com/webpack-contrib/url-loader)
**raw** - [raw-loader](https://github.com/webpack-contrib/raw-loader)
**html** - [html-loader](https://github.com/webpack-contrib/html-loader)
**json5** - [json5-loader](https://github.com/webpack-contrib/json5-loader)
**yaml** - [yaml-loader](https://github.com/webpack-contrib/yaml-frontmatter-loader)
**img** - [img-loader](https://github.com/thetalecrafter/img-loader)
*you may add more loaders later by manually editing the `webpack.config.js` file*
### DevServer
[official docs](https://webpack.js.org/configuration/dev-server/#devserver)
```
$ webpack-create-config ... -d ...
```
```
$ webpack-create-config ... --devserver ...
```
in `webpack.config.js`
```
...
devServer: {
contentBase: path.join(__dirname, 'dist'),
compress: true,
port: 9000,
},
...
```
also adds [webpack-dev-server](https://github.com/webpack/webpack-dev-server) as a dependency### Watch
[official docs](https://webpack.js.org/configuration/watch/)
```
$ webpack-create-config ... -w ...
```
```
$ webpack-create-config ... --watch ...
```
in `webpack.config.js`
```
...
watch: true,
watchOptions: {
ignored: /node_modules/,
},
...
```### Autoinstall
```
$ webpack-create-config ... -a ...
```
```
$ webpack-create-config ... --autoinstall ...
```
Automatically install all required dependecies (ex: webpack, file-loader, style-loader) with `npm install` (ex: `npm install -S webpack file-loader style-loader`)