Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@packmule/packmule

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@packmule/packmule

Stubborn configuration generator for webpack.

latest
Source
npmnpm
Version
1.3.4
Version published
Maintainers
2
Created
Source

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.

Generated webpack configuration
{
    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

Keywords

webpack

FAQs

Package last updated on 18 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts