0.0.2 • Published 5 years ago

webpack-alias-config-plugin v0.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

webpack-alias-config-plugin

Webpack plugin that provides a convenience to override modules require paths, with an external set of matching files.

Usage

// webpack.config.js
import WebpackAliasConfigPlugin from 'webpack-alias-config-plugin'

const webpackConfig = {
    plugins: [
        new WebpackAliasConfigPlugin({
            config: 'webpack.config.js',
            findConfig: true
        })
    ]
}

Installation

Install via npm:

npm install --save-dev webpack-alias-config-plugin

Api

new WebpackAliasConfigPlugin({ config, findConfig, extensions })
  • config(string): Path to your webpack config file.

    The plugin is going to look for a webpack.config.js file or a webpack.config.babel.js at the root, in case your webpack configuration file is in another location, you can use this option to provide an absolute or relative path to it. You can also use environment variable in this option, using lodash template, for example:

    const webpackConfig = {
        plugins: [
            new WebpackAliasConfigPlugin({
                config: "${PWD}/webpack.config.test.js",
            })
        ]
    }

    And run with:

    $ PWD=$(pwd) NODE_ENV=test ava
  • findConfig(boolean): Will find the nearest webpack configuration file when set to true.

    It is possible to pass a findConfig option, and the plugin will attempt to find the nearest webpack configuration file within the project using find-up. For example:

    const webpackConfig = {
        plugins: [
            new WebpackAliasConfigPlugin({
                config: "webpack.config.test.js",
                findConfig: true
            })
        ]
    }
  • extensions (optional) array of extensions to resolve against (default: 'jsx', 'js')