Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Webpack 2: No config found when config is a function #47

Open
giannif opened this issue Feb 14, 2017 · 1 comment
Open

Webpack 2: No config found when config is a function #47

giannif opened this issue Feb 14, 2017 · 1 comment

Comments

@giannif
Copy link

giannif commented Feb 14, 2017

Webpack 2 supports exporting a default function as the webpack config.

export default env => {
    // return env-specific configuration
}

I'm using this for the reasons in this post.

babel-plugin-webpack-alias will need to check for a function, invoke it (potentially with the value env), to get the config object, before it checks if config.resolve exists

Otherwise you get the 'The resolved config file doesn\'t contain a resolve configuration' error

@deldreth
Copy link

Ran into this recently. To get around the issue I created a separate alias file webpack.alias.js and added the resolve property to its export:

module.exports = {
  resolve: {
    alias: {
      something: 'something'
    }
  }
};

From your .babelrc you can specify that this plugin use this file.

From within your webpack config(s) require this file and set your main config's resolve to this object:

...
resolve: {
  alias: resolve.resolve.alias
},
...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants