webpack-bundle
TypeScript icon, indicating that this package has built-in type declarations

0.9.75 • Public • Published

webpack-bundle

The package helps to generate a webpack configuration and predefined bundles/options or both.

Build Status Coverage Status Greenkeeper badge

Getting starting

Install the package via npm or yarn

yarn add --dev webpack-bundle

or

npm i -D webpack-bundle

The package provide a simple API to define configuration. See a how-to example:

// webpack.config.ts
import {Bundle, Options} from "webpack-bundle";

const config = new Bundle();
config.set(
    new Options.Mode("production"),
    new Options.Module(/* module options */),
    new Options.Optimization(/* optimization options */),
    // ... another options
);

export default config.getWebpackConfig();

How to use TypeScript as a configuration language you can read here.

API

Full API documentation now available in source code only.

Custom Options

You can use custom (predefined) options like this:

// MySPAModule.ts
import {Options, Loader} from "webpack-bundle";

export class MySPAModule extends Options.Module {
    constructor() {
        super([
            new Loader({test: /\.tsx?$/, loader: "ts"}),
            new Loader({test: /\.css?$/, loader: "style"}),
            // add some more loaders...
        ]);
    }
}

use:

// webpack.config.ts
import {Bundle} from "webpack-bundle";
import {MySPAModule} from "./MySPAModule";

const bundle = new Bundle(
    new MySPAModule()
);

export default bundle.getWebpackConfiguration();

Custom Bundle

Write your bundles to your taste or like this:

// MySPABundle.ts
import {Bundle, Options, Loader} from "webpack-bundle";

export class MySPABundle extends Bundle {
    constructor() {
        super(
            new Options.Mode("development"),
            new Options.Module([
                new Loader({
                    test: /\.tsx?$/,
                    loader: "ts",
                    options: {
                        transpileOnly: true
                    }
                }),
            ]),
            // some other options...
        );
    }
}

use:

// webpack.config.ts

import {MySPABundle} from "./MySPABundle";

const bundle = new MySPABundle();
export default bundle.getWebpackConfiguration();

/webpack-bundle/

    Package Sidebar

    Install

    npm i webpack-bundle

    Weekly Downloads

    203

    Version

    0.9.75

    License

    MIT

    Unpacked Size

    75 kB

    Total Files

    148

    Last publish

    Collaborators

    • izatop