All Projects → webpack-contrib → config-loader

webpack-contrib / config-loader

Licence: MIT license
[DEPRECATED] A loader for webpack configuration files

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to config-loader

webpack-config
Webpack 5 configuration for static projects...
Stars: ✭ 96 (+585.71%)
Mutual labels:  webpack-configuration, webpack-config
plebpack
Webpack configuration for the common people.
Stars: ✭ 13 (-7.14%)
Mutual labels:  webpack-configuration, configuration
pyhaproxy
Python library to parse haproxy configurations
Stars: ✭ 50 (+257.14%)
Mutual labels:  configuration
eslint-config-kingstinct-react-native
Eslint configuration for React-native based on Airbnb with some great tweaks
Stars: ✭ 23 (+64.29%)
Mutual labels:  configuration
wormhole
A minimalistic Ansible-like tool for configuring remote servers via ssh
Stars: ✭ 22 (+57.14%)
Mutual labels:  configuration
emacs.d
Emacs configuration files
Stars: ✭ 15 (+7.14%)
Mutual labels:  configuration
go-contrib
Helper for Log configuration, Mixin for properties with fangs
Stars: ✭ 20 (+42.86%)
Mutual labels:  configuration
tomlj
A Java parser for Tom's Obvious, Minimal Language (TOML).
Stars: ✭ 72 (+414.29%)
Mutual labels:  configuration
profig
Powerful configuration management for Scala (JSON, properties, command-line arguments, and environment variables)
Stars: ✭ 25 (+78.57%)
Mutual labels:  configuration
tomland
🏝 Bidirectional TOML serialization
Stars: ✭ 103 (+635.71%)
Mutual labels:  configuration
spdlog setup
spdlog setup initialization via file configuration for convenience.
Stars: ✭ 68 (+385.71%)
Mutual labels:  configuration
react-initial-bootstrap
an "almost complete" template for your new projects
Stars: ✭ 24 (+71.43%)
Mutual labels:  configuration
jetrockets-standard
Standard RuboCop configuration for JetRockets with cookies
Stars: ✭ 14 (+0%)
Mutual labels:  configuration
dotfiles
Arch and bspwm dotfiles
Stars: ✭ 21 (+50%)
Mutual labels:  configuration
cmd-runner
Execute commands on remote hosts asynchronously over ssh
Stars: ✭ 24 (+71.43%)
Mutual labels:  configuration
steerage
Hapi server configuration and composition using confidence, topo, and shortstop.
Stars: ✭ 15 (+7.14%)
Mutual labels:  configuration
zcolors
🌈 Z Colors uses your $LS_COLORS to generate a coherent theme for Git and your Zsh prompt, command line and completions.
Stars: ✭ 38 (+171.43%)
Mutual labels:  configuration
parse it
A python library for parsing multiple types of config files, envvars & command line arguments that takes the headache out of setting app configurations.
Stars: ✭ 86 (+514.29%)
Mutual labels:  configuration
reload
Simple managed reload mechanism for Go
Stars: ✭ 18 (+28.57%)
Mutual labels:  configuration
neovim-config
Modern NeoVim config for IDE-like development
Stars: ✭ 89 (+535.71%)
Mutual labels:  configuration

npm node deps tests chat

config-loader

DEPRECATED. webpack-command is also deprecated. Please use webpack-cli. If any features were not implemented in webpack-cli feel free to create issue.

Why deprecated webpack-command ?

  • webpack-cli is very stable and have more features.
  • Two CLIs are misleading for developers.
  • Hard to maintain two package with same purpose.
  • The author stopped developing the package.
  • Most of the features are already implemented in webpack-cli.

Thanks for using webpack! We apologize for the inconvenience. In the future, we will avoid such situations.


A webpack configuration loader.

This module utilizes cosmiconfig which supports declaring a webpack configuration in a number of different file formats including; .webpackrc, webpack.config.js, and a webpack property in a package.json.

config-loader supports configuration modules which export an Object, Array, Function, Promise, and Function which returns a Promise.

The module also validates found configurations against webpack's options schema to ensure that the configuration is correct before webpack attempts to use it.

Requirements

This module requires a minimum of Node v6.9.0 and Webpack v4.0.0.

Getting Started

To begin, you'll need to install config-loader:

$ npm install @webpack-contrib/config-loader --save-dev

And get straight to loading a config:

const loader = require('@webpack-contrib/config-loader');
const options = { ... };

loader(options).then((result) => {
  // ...
  // result = { config: Object, configPath: String }
});

Extending Configuration Files

This module supports extending webpack configuration files with ESLint-style extends functionality. This feature allows users to create a "base" config and in essence, "inherit" from that base config in a separate config. A bare-bones example:

// base.config.js
module.exports = {
  name: 'base',
  mode: 'development',
  plugins: [...]
}
// webpack.config.js
module.exports = {
  extends: path.join(..., 'base-config.js'),
  name: 'dev'

The resulting configuration object would resemble:

// result
{
  name: 'dev',
  mode: 'development',
  plugins: [...]
}

The webpack.config.js file will be intelligently extended with properties from base.config.js.

The extends property also supports naming installed NPM modules which export webpack configurations. Various configuration properties can also be filtered in different ways based on need.

Read More about Extending Configuration Files

Gotchas

Function-Config Parameters

When using a configuration file that exports a Function, users of webpack-cli have become accustom to the function signature:

function config (env, argv)

webpack-cli provides any CLI flags prefixed with --env as a single object in the env parameter, which is an unnecessary feature. Environment Variables have long served the same purpose, and are easily accessible within a Node environment.

As such, config-loader does not call Function configs with the env parameter. Rather, it makes calls with only the argv parameter.

Extending Configuration Files in Symlinked Modules

When using extends to extend a configuration which exists in a different package, care must be taken to ensure you don't hit module resolution issues if you are developing with these packages with symlinks (i.e. with npm link or yarn link).

By default, Node.js does not search for modules through symlinks, and so you may experience errors such as:

module not found: Error: Can't resolve 'webpack-hot-client/client'

This can be fixed by using Node's --preserve-symlinks flag which will allow you to develop cross-module, without experiencing inconsistencies when comparing against a normal, non-linked install:

For webpack-command:

node --preserve-symlinks ./node_modules/.bin/wp

For webpack-serve:

node --preserve-symlinks ./node_modules/.bin/webpack-serve

Supported Compilers

This module can support non-standard JavaScript file formats when a compatible compiler is registered via the require option. If the option is defined, config-loader will attempt to require the specified module(s) before the target config is found and loaded.

As such, config-loader will also search for the following file extensions; .js, .es6, .flow, .mjs, and .ts.

The module is also tested with the following compilers:

Note: Compilers are not part of or built-into this module. To use a specific compiler, you must install it and specify its use by using the --require CLI flag.

API

loader([options])

Returns a Promise, which resolves with an Object containing:

config

Type: Object

Contains the actual configuration object.

configPath

Type: String

Contains the full, absolute filesystem path to the configuration file.

Options

allowMissing

Type: Boolean
Default: false

Instructs the module to allow a missing config file, and returns an Object with empty config and configPath properties in the event a config file was not found.

configPath

Type: String Default: undefined

Specifies an absolute path to a valid configuration file on the filesystem.

cwd

Type: String Default: process.cwd()

Specifies an filesystem path from which point config-loader will begin looking for a configuration file.

require

Type: String | Array[String] Default: undefined

Specifies compiler(s) to use when loading modules from files containing the configuration. For example:

const loader = require('@webpack-contrib/config-loader');
const options = { require: 'ts-node/register' };

loader(options).then((result) => { ... });

See Supported Compilers for more information.

schema

Type: Object Default: undefined

An object containing a valid JSON Schema Definition.

By default, config-loader validates your webpack config against the webpack config schema. However, it can be useful to append additional schema data to allow configs, which contain properties not present in the webpack schema, to pass validation.

Contributing

Please take a moment to read our contributing guidelines if you haven't yet done so.

CONTRIBUTING

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].