easy-webpack / core

An easy way to create configuration files for Webpack
MIT License
68 stars 6 forks source link

Strip non-conforming keys for Webpack 2.1.0-beta.23 schema validation #20

Closed niieani closed 7 years ago

niieani commented 7 years ago

See https://github.com/aurelia/skeleton-navigation/issues/670.

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration has an unknown property 'debug'. These properties are valid:
   object { amd?, bail?, cache?, context?, devServer?, devtool?, entry, externals?, loader?, module?, name?, dependencies?, node?, output?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, stats?, target?, watch?, watchOptions? }
 - configuration.entry['app'] should be one of these:
   string | [string]
   The entry point for one output file.
 - configuration.entry should be one of these:
   object { <key>: string | [string] } | string | [string]
   The entry point(s) of the compilation.
 - configuration.resolve has an unknown property 'root'. These properties are valid:
   object { modules?, descriptionFiles?, plugins?, mainFields?, aliasFields?, mainFiles?, extensions?, enforceExtension?, moduleExtensions?, enforceModuleExtension?, alias?, symlinks?, unsafeCache?, cachePredicate?, fileSystem?, resolver? }

┆Issue is synchronized with this Asana task

eikaramba commented 7 years ago

Just wanted to say that among the mentioned issues here and in the referenced ticket, also metadata needs to go from the root webpack config object to somewhere else.

This will involve changes at least in -core -config-css -config-aurelia -config-env-development & production

One way could be to load it via:

plugins: [
                new webpack.LoaderOptionsPlugin({
                    metadata: {
                            port: process.env.WEBPACK_PORT || 9000,
                            host: process.env.WEBPACK_HOST || 'localhost',
                            ENV: process.env.NODE_ENV || process.env.ENV || 'development',
                            HMR: hasProcessFlag('hot') || !!process.env.WEBPACK_HMR,
                        }
                }),

However i'm not so certain about this and also not about how to retrieve these values afterwards. Anyone with more knowledge about webpack might be able to help here.

niieani commented 7 years ago

I know how to solve this, it's just time that I haven't got. :/ Very much open to PRs on the matter though.

eikaramba commented 7 years ago

Sure, maybe i can help. My problem is just that i'm a webpack newbie and need a push in the right direction. :)

If you have the time can you quickly tell me where i can put the metadata in the config? Is my approach from above valid(via loaderoptionsplugin´)?

And if so, how can i retrieve the values from the easy-webpack plugins themself? Because this.root.metadata will not work anymore.

niieani commented 7 years ago

Fixed. Use latest major versions of all configs and the new stripMetadata function before exporting your config.