Giter Club home page Giter Club logo

webpack-config's Introduction

NPM version Travis build status AppVeyor build status Code Climate Maintainability Code Climate Coverage Dependency Status Development Dependency Status Greenkeeper badge

webpack-config

Helps to load, extend and merge webpack configs

Installation

npm install webpack-config --save-dev

or

yarn add webpack-config --dev

Features

  • #extend() - Helps to extend config using local file or shareable config
  • #merge() - Helps to merge some values into config and overrides existing ones
  • #defaults() - Helps to add some values if they are missing
  • Supports environment variables under #extend(), #merge(), #defaults() methods
  • Supports process.env.* variables in addition to environment ones
  • Supports shareable configs via node-modules

Changelog

Details changes for each release are documented in the release notes and also in the wiki page.

Shareable Configs

You can publish your configs to npm using webpack-config- prefix for package name.

When you call #extend() method you may omit that prefix:

import Config from "webpack-config";

export default new Config().extend(
  "mdreizin/base",
  "mdreizin/css",
  "mdreizin/html",
  "webpack-config-mdreizin/json"
  // etc
);

Also I would recommend to add webpack and webpack-config keywords so other users can easily find your module.

Usage

./webpack.config.js

import Config, { environment } from "webpack-config";

environment.setAll({
  env: () => process.env.NODE_ENV
});

// Also you may use `'conf/webpack.[NODE_ENV].config.js'`
export default new Config().extend("conf/webpack.[env].config.js");

./conf/webpack.base.config.js

import ExtractTextPlugin from "extract-text-webpack-plugin";
import Config from "webpack-config";

const extractCss = new ExtractTextPlugin("[name].css");

export default new Config().merge({
  output: {
    filename: "[name].js"
  },
  resolve: {
    root: [__dirname],
    modulesDirectories: ["node_modules"]
  },
  plugins: [extractCss],
  module: {
    loaders: [
      {
        test: /\.less$/,
        loader: extractCss.extract("style", ["css", "less"])
      }
    ]
  }
});

./conf/webpack.development.config.js

import webpack from "webpack";
import Config from "webpack-config";

export default new Config().extend("conf/webpack.base.config.js").merge({
  debug: true,
  devtool: "#source-map",
  output: {
    pathinfo: true
  },
  entry: {
    app: ["src/index.js", "src/index.less"],
    vendor: ["lodash"]
  },
  plugins: [new webpack.optimize.CommonsChunkPlugin("vendor", "vendor.js")]
});

./conf/webpack.production.config.js

import webpack from "webpack";
import Config from "webpack-config";

export default new Config()
  .extend({
    "conf/webpack.development.config.js": config => {
      delete config.debug;
      delete config.devtool;
      delete config.output.pathinfo;

      return config;
    }
  })
  .merge({
    plugins: [
      new webpack.optimize.DedupePlugin(),
      new webpack.optimize.OccurrenceOrderPlugin(true),
      new webpack.optimize.UglifyJsPlugin({
        mangle: true,
        output: {
          comments: false
        },
        compress: {
          warnings: false
        }
      })
    ]
  });

webpack-config's People

Contributors

efueger avatar greenkeeper[bot] avatar greenkeeperio-bot avatar mdreizin avatar simenb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

webpack-config's Issues

List breaking changes in v5

Manually comparing old vs new API is a no-go, it's too large for that.

Keeping a CHANGELOG would be nice as well 😄

An in-range update of semantic-release is breaking the build 🚨

The devDependency semantic-release was updated from 15.13.11 to 15.13.12.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

semantic-release is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/appveyor/branch: AppVeyor build failed (Details).
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes for v15.13.12

15.13.12 (2019-04-15)

Bug Fixes

  • package: update resolve-from to version 5.0.0 (6f3c21a)
Commits

The new version differs by 1 commits.

  • 6f3c21a fix(package): update resolve-from to version 5.0.0

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml
  • The new Node.js version is in-range for the engines in 1 of your package.json files, so that was left alone

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Prepend entry point

I have two configuration: local and HMR. In HMR I'd like to override the entry point to prepend the webpack-dev-server related things:

var config = Config.fromObject({
    entry: ['file.js'],
});

if (hmr) {
    config = config.merge({
        entry: [
            'webpack-dev-server/client',
            'webpack/hot/only-dev-server',
        ],
    });
}

However of course when I do this, the HMR related entry points are added after my actual entry point. Is there any way to prepend instead of append?

Currently manually overriding config.entry afterwards but that's not ideal:

config.entry = [
    'webpack-dev-server/client',
    'webpack/hot/only-dev-server',
].concat(config.entry);

webpack 2 command line arguments are lost

Hi,

Webpack 2 dictates the way of passing custom command line arguments:
webpack/webpack#2254

So we can have dynamic configs.

I've tried to apply the same logic to the configs which are processed using webpack-config, but found that it doesn't work as expected.

Here is the repository to reproduce the issue:
https://github.com/PavelPolyakov/webpack-config-env-issue

Basically, when I run webpack and pass the variable env.hello, I want my base config to be extended.

During the run, I see that it is invoked twice, first time the env variable is there, but the second time I have some Config object.

image

I'd appreciate a help, maybe I'm doing something wrong.

Regards,

more info on environment support

I am trying to find out more info about these two features:

  • Supports environment variables under #extend(), #merge(), #defaults() methods
  • Supports process.env.* variables in addition to environment ones

I see that in the readme there's

// Also you may use `'conf/webpack.[NODE_ENV].config.js'`

Is there more info somewhere else?

Error in `v6.1.1`

Hello,
I updated to v6.1.1. Getting this error. I managed to track down to the ConfigMergeCommand not resolving extend path /home/mohan/vc-portal/client/webpack.config.[env].js'

/home/mohan/project/vc-portal/node_modules/webpack-config/dist/Config.js:101
        throw _iteratorError;
        ^

ReferenceError: name is not defined
    at eval (lodash.templateSources[5]:9:10)
    at ConfigPatternCache._eval (/home/mohan/project/vc-portal/node_modules/webpack-config/dist/ConfigPatternCache.js:125:20)
    at ConfigNameResolver.resolve (/home/mohan/project/vc-portal/node_modules/webpack-config/dist/ConfigNameResolver.js:98:32)
    at ConfigOptionsResolver.resolve (/home/mohan/project/vc-portal/node_modules/webpack-config/dist/ConfigOptionsResolver.js:94:45)
    at ConfigMergeCommand.execute (/home/mohan/project/vc-portal/node_modules/webpack-config/dist/ConfigMergeCommand.js:59:46)
    at executeCommand (/home/mohan/project/vc-portal/node_modules/webpack-config/dist/Config.js:89:15)
    at Config.merge (/home/mohan/project/vc-portal/node_modules/webpack-config/dist/Config.js:198:29)
    at Object.<anonymous> (webpack.config.base.js:119:29)
    at Module._compile (module.js:541:32)
    at loader (/home/mohan/project/vc-portal/node_modules/babel-register/lib/node.js:148:5)
    at Object.require.extensions.(anonymous function) [as .js] (/home/mohan/project/vc-portal/node_modules/babel-register/lib/node.js:158:7)

Modifying loader/plugins options

This may be out of the scope of webpack-config and I'm aware you're working over at the Webpack repo to make its configuration more extensible, but would there be any way to make this package handle overriding options of loaders and/or plugins?

Currently this is one of the pain point of having loaders being defined as an array, imagine you have this:

const config = Config.fromObject({
   module: {
       loaders: [
           {
               test: /\.css$/,
               loaders: ['css'],
           }
       ]
   }
});

If in production I wanted to makes CSS also be processed by Autoprefixer I would have to do something like:

config.module.loaders[0].loaders.push('autoprefixer');

With 0 being kind of a magic number and being very susceptible to break. Would that be solvable in any way or is something improving that area coming to the next version of the package?

An in-range update of jsdoc is breaking the build 🚨

Version 3.5.0 of jsdoc just got published.

Branch Build failing 🚨
Dependency jsdoc
Current Version 3.4.3
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As jsdoc is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪

Status Details
  • dependency-ci Dependencies checked Details
  • continuous-integration/appveyor/branch AppVeyor build failed Details
  • continuous-integration/travis-ci/push The Travis CI build passed Details

Release Notes JSDoc 3.5.0

This version of JSDoc includes the following major changes:

  • JSDoc now uses the Babylon JavaScript parser, which means that
    JSDoc can parse any JavaScript or JSX file that is supported by the Babel
    compiler.
  • You can now use a JavaScript file to configure JSDoc. See the
    documentation for details and examples.
  • Fixed multiple issues with documenting ES2015 classes and modules.
  • JSDoc now requires Node.js 4.2.0 or later.

For a complete list of changes, see the changelog on GitHub.

Commits

The new version differs by 112 commits ahead by 112, behind by 45.

  • cdd00c0 3.5.0
  • 50d6119 update 3.5.0 changelog
  • e94a598 3.5.0 changelog
  • 5d0b690 reformat changelog
  • c50a4c0 add yields tag (#1388)
  • f31a011 resolve the path to the JS config file before requiring it (#1386)
  • d95cbdd support namespaces that are also functions (#955)
  • 9f8853a add hideconstructor tag (#952)
  • ca1c4f2 add package tag (#962)
  • 6275e69 autodetect default and repeatable parameters when a function is assigned to a variable (#1054)
  • 0e4f1a9 correctly document constructors and instance properties of ES2015 classes (#1182)
  • 67db938 add sourceType config option
  • f101798 fix crash when the author tag is empty (#1289)
  • 43a117d add recurseDepth config option (#1340)
  • 8f5c60b support bigint

There are 112 commits in total.

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

An in-range update of babel-plugin-transform-builtin-extend is breaking the build 🚨

Version 1.1.1 of babel-plugin-transform-builtin-extend just got published.

Branch Build failing 🚨
Dependency babel-plugin-transform-builtin-extend
Current Version 1.1.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As babel-plugin-transform-builtin-extend is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪


Status Details
  • dependency-ci Dependencies checked Details

  • continuous-integration/appveyor/branch AppVeyor build succeeded Details

  • continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Commits

The new version differs by 3 commits .

See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

An in-range update of codeclimate-test-reporter is breaking the build 🚨

Version 0.4.1 of codeclimate-test-reporter just got published.

Branch Build failing 🚨
Dependency codeclimate-test-reporter
Current Version 0.4.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As codeclimate-test-reporter is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪


Status Details
  • dependency-ci Dependencies checked Details

  • continuous-integration/appveyor/branch AppVeyor build succeeded Details

  • continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Commits

The new version differs by 3 commits .

See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

An in-range update of eslint is breaking the build 🚨

Version 3.16.0 of eslint just got published.

Branch Build failing 🚨
Dependency eslint
Current Version 3.15.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As eslint is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪


Status Details
  • dependency-ci Dependencies checked Details

  • continuous-integration/appveyor/branch AppVeyor build succeeded Details

  • continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Release Notes v3.16.0
  • d89d0b4 Update: fix quotes false negative for string literals as template tags (#8107) (Teddy Katz)
  • 21be366 Chore: Ensuring eslint:recommended rules are sorted. (#8106) (Kevin Partington)
  • 360dbe4 Update: Improve error message when extend config missing (fixes #6115) (#8100) (alberto)
  • f62a724 Chore: use updated token iterator methods (#8103) (Kai Cataldo)
  • daf6f26 Fix: check output in RuleTester when errors is a number (fixes #7640) (#8097) (alberto)
  • cfb65c5 Update: make no-lone-blocks report blocks in switch cases (fixes #8047) (#8062) (Teddy Katz)
  • 290fb1f Update: Add includeComments to getTokenByRangeStart (fixes #8068) (#8069) (Kai Cataldo)
  • ff066dc Chore: Incorrect source code test text (#8096) (Jack Ford)
  • 14d146d Docs: Clarify --ext only works with directories (fixes #7939) (#8095) (alberto)
  • 013a454 Docs: Add TSC meeting quorum requirement (#8086) (Kevin Partington)
  • 7516303 Fix: sourceCode.getTokenAfter shouldn't skip tokens after comments (#8055) (Toru Nagashima)
  • c53e034 Fix: unicode-bom fixer insert BOM in appropriate location (fixes #8083) (#8084) (pantosha)
  • 55ac302 Chore: fix the timing to define rules for tests (#8082) (Toru Nagashima)
  • c7e64f3 Upgrade: mock-fs (#8070) (Toru Nagashima)
  • acc3301 Update: handle uncommon linebreaks consistently in rules (fixes #7949) (#8049) (Teddy Katz)
  • 591b74a Chore: enable operator-linebreak on ESLint codebase (#8064) (Teddy Katz)
  • 6445d2a Docs: Add documentation for /* exported */ (fixes #7998) (#8065) (Lee Yi Min)
  • fcc38db Chore: simplify and improve performance for autofix (#8035) (Toru Nagashima)
  • b04fde7 Chore: improve performance of SourceCode constructor (#8054) (Teddy Katz)
  • 90fd555 Update: improve null detection in eqeqeq for ES6 regexes (fixes #8020) (#8042) (Teddy Katz)
  • 16248e2 Fix: no-extra-boolean-cast incorrect Boolean() autofixing (fixes #7977) (#8037) (Jonathan Wilsson)
  • 834f45d Update: rewrite TokenStore (fixes #7810) (#7936) (Toru Nagashima)
  • 329dcdc Chore: unify checks for statement list parents (#8048) (Teddy Katz)
  • c596690 Docs: Clarify generator-star-spacing config example (fixes #8027) (#8034) (Hòa Trần)
  • a11d4a6 Docs: fix a typo in shareable configs documentation (#8036) (Dan Homola)
  • 1e3d4c6 Update: add fixer for no-unused-labels (#7841) (Teddy Katz)
  • f47fb98 Update: ensure semi-spacing checks import/export declarations (#8033) (Teddy Katz)
  • e228d56 Update: no-undefined handles properties/classes/modules (fixes #7964) (#7966) (Kevin Partington)
  • 7bc92d9 Chore: fix invalid test cases (#8030) (Toru Nagashima)
Commits

The new version differs by 31 commits .

  • 3c26a59 3.16.0
  • 5bdb960 Build: package.json and changelog update for 3.16.0
  • d89d0b4 Update: fix quotes false negative for string literals as template tags (#8107)
  • 21be366 Chore: Ensuring eslint:recommended rules are sorted. (#8106)
  • 360dbe4 Update: Improve error message when extend config missing (fixes #6115) (#8100)
  • f62a724 Chore: use updated token iterator methods (#8103)
  • daf6f26 Fix: check output in RuleTester when errors is a number (fixes #7640) (#8097)
  • cfb65c5 Update: make no-lone-blocks report blocks in switch cases (fixes #8047) (#8062)
  • 290fb1f Update: Add includeComments to getTokenByRangeStart (fixes #8068) (#8069)
  • ff066dc Chore: Incorrect source code test text (#8096)
  • 14d146d Docs: Clarify --ext only works with directories (fixes #7939) (#8095)
  • 013a454 Docs: Add TSC meeting quorum requirement (#8086)
  • 7516303 Fix: sourceCode.getTokenAfter shouldn't skip tokens after comments (#8055)
  • c53e034 Fix: unicode-bom fixer insert BOM in appropriate location (fixes #8083) (#8084)
  • 55ac302 Chore: fix the timing to define rules for tests (#8082)

There are 31 commits in total. See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

TypeError: Config is not a constructor

Hi there, I'd love to be using this awesome library for managing my webpack configs, but I'm having some issues getting it working. I'm using Node 6.3.1 and importing the library with var Config = require('webpack-config); but I'm getting the error in the screenshot below. I also get the same TypeError when trying to import with var Config = require('webpack-config').Config instead. I believe I'm doing something wrong, but I can't tell what. I know the documentation is using import statements, but Node doesn't seem to support these even in the latest stable release.

image

Config environment variable not replaced by merge

Hi,

I would like to do be able to build multiple variations of the same app.
Very basic example:

webpack.config.js

ConfigEnvironment.INSTANCE.setAll({
    env: () => process.env.WEBPACK_ENV || process.env.NODE_ENV
    theme: () => argv.THEME || 'default'
});

export default new Config().extend('./webpack.base.config.js');

webpack.base.config.js

export default new Config().merge({
    entry: 'path/[theme]/App.js'
    ...
});

[theme] is not replaced when used with merge.
.extend('./webpack.[theme].config.js') would work.

Is there a reason why [theme] is not replaced by merge?

Thank you

Multiple environments at once - as array.

Hey.

So, my WebPack config has crossed the 400th LoC. Holy ... y'know. ITS BIG.

The idea is, to split it into pieces. In order to do so, I looked at this module. Now I have a few questions:

  • Can I have two environments at once?
    WebPack's compiler API allows for an array to be supplied, which just spawns two compilers. That would be useful for taking notes of the differences between dev and production without having to stop the server.
  • Is there a clear documentation of the functions? I kinda have to puzzle it together from the README.

Kind regards,
Ingwie

Externals must be arrays in order to merge

The following works if both are arrays:

var Config = require('webpack-config').Config;

var config = new Config();
config.merge({
    externals: {
        'foo': 'bar'
    }
});

config.merge({
    externals: [
        {
          'fizz': 'buzz'
        }
    ]
});

console.log(config);  \\ "Config { externals: [ { fizz: 'buzz' } ] }"

An in-range update of eslint-plugin-babel is breaking the build 🚨

Version 4.1.0 of eslint-plugin-babel just got published.

Branch Build failing 🚨
Dependency eslint-plugin-babel
Current Version 4.0.1
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As eslint-plugin-babel is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪


Status Details
  • dependency-ci Dependencies checked Details

  • continuous-integration/appveyor/branch AppVeyor build succeeded Details

  • continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Release Notes v4.1.0

New

  • babel/semi: Includes class properties (🛠 )
Commits

The new version differs by 2 commits .

See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

[Help Needed] Override environment variables when multiple webpack files are derived.

I have an issue in way we reuse environment variables per config. Let me explain below

  1. There is a base.webpack.js which holds my basic config
// base.webpack.js
...
context: '[appContext]',
...
  1. I have an helper function, which sets the appContext based on if its server or client code, since they live in two separate packages.
// webpack.helper.js
import Config, { environment } from 'webpack-config'

/*  Basic helper that fetches respective config based on the path and configName.

     localWebpackPath -> e.g. /path/to/server/webpack,
     localContextPath -> e.g. /path/to/server/src
     localConfigName -> e.g. server.webpack.js
*/
export function fetchConfig(
	localWebpackPath,
	localContextPath,
	localConfigName = ''
) {

// based on who invoked set the environment variables.
environment.setAll({
		root: () => 'path/to/common/webpack/files',   // root has base.js, prod.js, dev.js
		appContext: localContextPath  // source of the target webpack to resolve modules
	})

const toExport = []

//based on the name and location fetch the config.
toExport.push(...load(localConfigName, localWebpackPath)

if (!toExport.length) {
		// if no config could be constructed throw error.
		console.error('Error: WEBPACK_CONFIG files not given')
		process.exit()
	}

return toExport

}

// Helper to require the webpack file and merge them to one incase they exported arrays.
function load(file, localpath = '') {
	try {
		wp = require(path.resolve(localpath, file)).default
	} catch (e) {
		console.error(`Error: ${file}.js not found or has errors:`) // eslint-disable-line no-console
		console.error(e) // eslint-disable-line no-console
		process.exit()
	}

	// If the config isn't already an array, add it to a new one, map over each
	// `webpack-config`, and create a 'regular' Webpack-compatible object
	return (Array.isArray(wp) ? wp : [wp]).map(config =>
		new Config().merge(config).toObject()
	)
}
...
  1. webpack.config.babel.js that invokes server.webpack.js
// client/webpack.config.babel.j
import { fetchConfig } from 'path/to/common/helpers/webpack.helper'
import path from 'path'

const localWebpackPath = path.join(__dirname, 'webpack')
const localContextPath = path.join(__dirname, 'src')
let localConfigName = 'client.webpack.js'

// just feed the path, based on the environment, helper will pick the corresponding webpack file.
export default fetchConfig(localWebpackPath, localContextPath, localConfigName)
------------------------------------------------------------------------------------------------
// server/webpack.config.babel.j
import { fetchConfig } from 'path/to/common/helpers/webpack.helper'
import path from 'path'

const localWebpackPath = path.join(__dirname, 'webpack')
const localContextPath = path.join(__dirname, 'src')
let localConfigName = 'server.webpack.js'

// just feed the path, based on the environment, helper will pick the corresponding webpack file.
export default fetchConfig(localWebpackPath, localContextPath, localConfigName)

Now i can invoke and get the files merged, but the context got from base.js to server/client webpack files always have the one injected when client webpack was invoked.

Not sure what i'm missing out here or if the recommended way to inject the environment/reusable variable is wrong. Please let me know if there is way to achieve this.

Extending duplicate deeply-nested configs

Problem: I am using Nuxt.js which exports an extendable config for webpack. I'd like to extend "sass-loader" in that config, BUT...

  1. The root list of module loaders contains both "vue-loader" and "sass-loader", with respective options.
  2. Under "vue-loader" options, it contains a loaders property, which has a sub-property of sass, which contains an array of loaders, ONE of which is "sass-loader", which then, of course has a list of duplicated options for "sass-loader".

I'd like to use webpack-config to extend/merge instances of "sass-loader" wherever { loader: 'sass-loader' } is found in the entire config sub-tree. (Ideally, I would also check that the exported config doesn't have any variation between duplicate loader options.)

Can a feature be added where merging includes a deep key/value lookup of the object tree, and then merges the options at that location? Or can you think of another way to do this?

Thanks.

TypeError: Cannot read property 'extend' of undefined

With version 7.3.0 does not work. Everything is ok with version 7.0.0

TypeError: Cannot read property 'extend' of undefined
    at Object.<anonymous> (/scripts/webpack/development.config.js:10:16)
    at Module._compile (module.js:570:32)
    at loader (/node_modules/babel-register/lib/node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (/node_modules/babel-register/lib/node.js:154:7)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at ConfigCache.get (/node_modules/webpack-config/src/ConfigCache.js:89:25)

Using require instead of import?

All the examples show the usage of import but I can't manage to get the damn config files to go through babel or whatever is necessary and already wasted hours on this.

So how do I do the same using require() or what do I need to do to get webpack3 to work with babel and import?

In need of a bit more documentation

This package is a great help, but the documentation isn't helping me much harnessing it at its full power. Could we have more informations on the difference between merge and extends? What does default do? What are MultiConfigs?

npm install fails

When you have the following error:

npm ERR! argv "/usr/local/Cellar/node/4.1.1/bin/node" "/usr/local/bin/npm" "i" "webpack-config"
npm ERR! node v4.1.1
npm ERR! npm  v2.14.4
npm ERR! code E404

npm ERR! 404 Registry returned 404 for GET on https://registry.npmjs.org/webpack-config
npm ERR! 404 
npm ERR! 404 'webpack-config' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 It was specified as a dependency of 'gulp-webpack-build'
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

I'm working on that.

Please use as temporary solution:

{
  "webpack-config": "mdreizin/webpack-config#v0.8.0"
}

or

{
  "webpack-config": "0.8.1"
}

Please accept my apologies for any inconvenience.

An in-range update of babel-runtime is breaking the build 🚨

Version 6.25.0 of babel-runtime just got published.

Branch Build failing 🚨
Dependency babel-runtime
Current Version 6.23.0
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

babel-runtime is a direct dependency of this project this is very likely breaking your project right now. If other packages depend on you it’s very likely also breaking them.
I recommend you give this issue a very high priority. I’m sure you can resolve this 💪

Status Details
  • dependency-ci Dependencies checked Details
  • continuous-integration/appveyor/branch AppVeyor build succeeded Details
  • continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Deep loader query objects are reserialized incorrectly

Hi @mdreizin!

We're having an issue over at stylus-relative-loader that I think I tracked down to webpack-config. We're on the latest, 6.1.2.

To summarize, this loader string goes in:

stylus-relative-loader?{"precacheImportVariables":[{"$tenant":"sams"},{"$tenant":"walmart"}]}

and after a WebpackConfig().merge(...), this comes out:

stylus-relative-loader?{"precacheImportVariables":[object Object]}

^ notice how it clobbered our array! 😱 The original nested object was a totally legit query.

I haven't dug into the webpack-config code yet, but I think it might be a bigger issue than just reserializing our object poorly: webpack says that queries can be any old arbitrary syntax and it's the loader's job to parse them – many just happen to use parseQuery from loader-utils which lets you put JSON5 there, but it's not a requirement. I think it's too presumptuous of webpack-config to think it can parse a stringified query. If the loader is already non-stringified (specified like { loader: "foo", query: { ... } }), then sure, but otherwise there's potential breakage.

I'll start digging into the code but would of course appreciate any help. :)

/cc @jmcriffey

Doesn't work with webpack 2

 WebpackOptionsValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration has an unknown property 'DEPENDENCY_TREE'. These properties are valid:
   object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry, externals?, loader?, module?, name?, node?, output?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, stats?, target?, watch?, watchOptions? }
   For typos: please correct them.
   For loader options: webpack 2 no longer allows custom properties in configuration.
     Loaders should be updated to allow passing options via loader options in module.rules.
     Until loaders are updated one can use the LoaderOptionsPlugin to pass these options to the loader:
     plugins: {
       new webpack.LoaderOptionsPlugin({
         // test: /\.xxx$/, // may apply this only for some modules
         options: {
           DEPENDENCY_TREE: ...
         }
       })
     }

Looks like Webpack 2 doesnt like any additional properties inside configuration object that shouldn't be there. Is there any workaround for this? Can i somehow remove this DEPENDENCY_TREE object?

An in-range update of babel-cli is breaking the build 🚨

Version 6.23.0 of babel-cli just got published.

Branch Build failing 🚨
Dependency babel-cli
Current Version 6.22.2
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As babel-cli is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪


Status Details
  • dependency-ci Dependencies checked Details

  • continuous-integration/appveyor/branch AppVeyor build succeeded Details

  • continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Feature: optional extend (aka silently fail on missing file)

right now we have two ways to build up an eventual configuration object from other files:


export default new Config().extend({
  'core/foo': (config) => {
    config.bar.forEach( (item) => { item.name = `${item.name}-foo`; })
  }
})

or

export default new Config()
  .extend('core/foo');

At the moment, if core/foo doesn't exist, then an error is thrown.

instead, let's specify a way to relax errors for missing files, then default to extending an empty object.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.