Skip to content
This repository has been archived by the owner on Nov 15, 2019. It is now read-only.

Document name and Move Example #54

Open
skipjack opened this issue Jun 25, 2017 · 4 comments
Open

Document name and Move Example #54

skipjack opened this issue Jun 25, 2017 · 4 comments

Comments

@skipjack
Copy link

skipjack commented Jun 25, 2017

Moving this issue from webpack/webpack.js.org#1330 (originally webpack/webpack#5144)...

See the comments in the originals but essentially the issue is that in the example on the main repo, there is a name option passed to the actual webpack config which isn't mentioned in this package's readme, the example, or in the main webpack configuration documentation:

var path = require("path");
var I18nPlugin = require("i18n-webpack-plugin");
var languages = {
	"en": null,
	"de": require("./de.json")
};
module.exports = Object.keys(languages).map(function(language) {
	return {
		name: language, // <= THIS PROPERTY
		entry: "./example",
		output: {
			path: path.join(__dirname, "js"),
			filename: language + ".output.js"
		},
		plugins: [
			new I18nPlugin(
				languages[language]
			)
		]
	};
});

I dug through the code a bit but couldn't figure out if or how that name property is used. Does this plugin actually use it in some way or does it just help identify locale-specific configs while debugging?

I would suggest two things (and I'd be happy to help with them):

  1. If it is used, document how it affects the end user and why it's required.
  2. I think we should move the example, maybe barring the actual output to this repository.

The second is more of an overall thing... I think those examples at the main repo lead to a bit of confusion for users. Imho they should either be located in the docs repo or the repo for the package they describe. I think I or @hovissimo would be happy to help push this forward just looking for some advice/clarification.

@michael-ciniawsky
Copy link
Member

I give the standardisation REDAME overhaul here some priority :), if someone with more experience using the plugin (@sullenor) could help to clearify the usage of name, would be appreciated 😛

@sullenor
Copy link
Collaborator

sullenor commented Aug 3, 2017

@skipjack as far as I know the i18n plugin doesn't use the name option in its code.

Since the example describes the two configurations (one for each language) I assume that the name is used here to identify the configs, so you may be able to execute only one from cli by its name.
webpack/webpack@3c77b07

Check this out:

webpack --config-name de
webpack --config-name en

@skipjack
Copy link
Author

skipjack commented Aug 5, 2017

@sullenor thanks for that clarification, your description makes sense. Can you point me to an example or the source code where that --config-name flag is made available? I've never seen it used before, though I also haven't done much with i18n and webpack. I did do a quick search through the CLI repository for that flag but didn't see anything.

@sullenor
Copy link
Collaborator

sullenor commented Aug 5, 2017

@skipjack looks like it was added in webpack version 3.4.0 (just found the release note) and implemented in that commit webpack/webpack@3c77b07

The option can be used in case you have multi-compilation (your's webpack config expose an array of configurations). Using it you may choose particular configurations to run. I guess it was added to solve some performance issues :)

Here is another example of usage https://github.com/webpack/webpack/tree/master/examples/multi-compiler#webpackconfigjs

I'm not quite familiar with webpack-cli repo, but webpack has a cli interface build in: https://github.com/webpack/webpack/blob/master/bin/config-optimist.js

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

No branches or pull requests

3 participants