Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibility to load only specified languages? #36

Closed
qqilihq opened this issue Jan 13, 2017 · 4 comments
Closed

Possibility to load only specified languages? #36

qqilihq opened this issue Jan 13, 2017 · 4 comments

Comments

@qqilihq
Copy link

qqilihq commented Jan 13, 2017

This module looks awesome and I would like to replace our self curated languages lists with it.

As I would like to use it in our web apps, my question: Is it possible to load only specified languages instead of the entire list? We would currently only require two languages and I would like to save transfer bandwidth.

@vpithart
Copy link

Yes, there is a way.

package.json
"i18n-iso-countries": "^1.7.1"

webpack.common.js. in module.exports:

module: {
    exprContextCritical: false,
    rules: [
      {
        // Pack EN and FR only; don't load languages we don't need
        test: /node_modules\/i18n-iso-countries\/langs\/.*\.json$/,
        exclude: /langs\/(en|fr)\.json$/,
        loader: 'null-loader'
      },
      ... other rules
}

This way, only en and fr are webpacked. Footprint shrinks from 402 kB (all languages) to 118kB.

@qqilihq
Copy link
Author

qqilihq commented Jan 13, 2017

Thank you, vpithart! We're (still?!) using Browserify though, is there a similar mechanism?

@vpithart
Copy link

Don't know, sorry. Perhaps an impulse to switch to webpack?

@qqilihq
Copy link
Author

qqilihq commented Jan 13, 2017

Most definitely :)

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

No branches or pull requests

3 participants