@packmule/packmule
Stubborn configuration generator for webpack.
Last updated 5 months ago by thasmo .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @packmule/packmule 
SYNC missed versions from official npm registry.

packmule ???? ????

Stubborn configuration generator for webpack.

packmule is an opinionated, plugin-based configuration-generator for webpack.

Biased Features

  • Various webpack options are pre-configured to work with HTTP2 at an optimum by default.
  • Bundled packs have been developed and tested for specific use cases.

Supported Functionality

  • Replace any bundled pack with your own custom pack.
  • Add your own pack to generate custom webpack configuration.
  • Use the bundled raw pack to add custom webpack configuration directly.

Installation

Run the following command within your project directory to install packmule.

npm install --save-dev @packmule/packmule

Example

import Packmule, {
    EntryPack,
    OutputPack,
    SassPack,
    TypeScriptPack,
    CompressionPack,
} from '@packmule/packmule';

const packmule = new Packmule(mode);
packmule.register(new EntryPack('main.ts'));
packmule.register(new OutputPack('public/', '/'));
packmule.register(new SassPack());
packmule.register(new TypeScriptPack());

if (mode === 'production') {
    packmule.register(new CompressionPack());
}

return packmule.generate();

packmule will generate the following configuration for webpack on the fly, running webpack --mode production; it's simplified and shortened to make it more readable.

<summary>Generated webpack configuration</summary>
{
    mode: 'production',
    cache: false,
    entry: {
        main: ['source/main.ts'],
    },
    output: {
        path: '/public',
        publicPath: '/',
        filename: '[name].[contenthash:8].js',
        chunkFilename: 'chunks/[name].[contenthash:8].js',
    },
    resolve: {
        extensions: ['.json', '.scss', '.sass', '.ts', '.tsx'],
    },
    plugins: [
        HashedModuleIdsPlugin,
        MiniCssExtractPlugin,
        CompressionPlugin,
    ],
    optimization: {
        splitChunks: {
            minSize: 0,
            minChunks: 1,
        },
        minimizer: [
            TerserPlugin,
            OptimizeCssAssetsWebpackPlugin,
        ],
    },
    module: {
        rules: [
            {
                test: /\.s[ac]ss$/,
                use: ['node_modules/mini-css-extract-plugin/dist/loader.js',
                    {
                        loader: 'css-loader',
                        options: {
                            sourceMap: false,
                        },
                    },
                    {
                        loader: 'postcss-loader',
                        options: {
                            sourceMap: false,
                        },
                    },
                    {
                        loader: 'sass-loader',
                    },
                ],
            },
            {
                test: /\.tsx?$/,
                use: [{
                        loader: 'babel-loader',
                        options: {
                            cacheDirectory: false,
                        },
                    },
                    {
                        loader: 'ts-loader',
                        options: {
                            logLevel: 'warn',
                            transpileOnly: true,
                            onlyCompileBundledFiles: true,
                            compilerOptions: {
                                sourceMap: false,
                            },
                        },
                    },
                ],
            },
        ],
    },
}

Documentation

License

MIT


Current Tags

  • 1.2.0                                ...           latest (5 months ago)
  • 1.3.0-rc.0                                ...           next (4 months ago)

8 Versions

  • 1.3.0-rc.0                                ...           4 months ago
  • 1.2.0                                ...           5 months ago
  • 1.2.0-rc.1                                ...           6 months ago
  • 1.2.0-rc.0                                ...           6 months ago
  • 1.1.1                                ...           7 months ago
  • 1.1.0                                ...           7 months ago
  • 1.0.1                                ...           7 months ago
  • 1.0.0                                ...           a year ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |