npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

webpack-create-config

v1.0.0

Published

A tool for creating webpack config

Downloads

2

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 <filename>     Entry point/points to build your project
    -o, --output <filename>    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

official docs

-e, --entry required

Single file

$ 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

-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

-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

-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

-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

less - less-loader

sass - sass-loader

json - json-loader

coffee - coffee-loader

file - file-loader

url - url-loader

raw - raw-loader

html - html-loader

json5 - json5-loader

yaml - yaml-loader

img - img-loader

you may add more loaders later by manually editing the webpack.config.js file

DevServer

official docs

$ 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 as a dependency

Watch

official docs

$ 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)