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

Use DefinePlugin instead of env-replace #40

Closed
alexilyaev opened this issue Oct 22, 2015 · 0 comments
Closed

Use DefinePlugin instead of env-replace #40

alexilyaev opened this issue Oct 22, 2015 · 0 comments

Comments

@alexilyaev
Copy link
Contributor

Right now there's a preloader env-replace that goes through all files and replaces @@PROPERTY with the values in environments.json.

Then this file is imported and set as a constant on the app module.

That's ok, but Webpack already has a solution for that exact scenario:

// Define global variables that will be available in any chunk
new webpack.DefinePlugin({
  ENV: process.env.NODE_ENV,
  API_URL: appConfig.API_URL
})

This adds variables that are available in all imported modules (not on window just the global Webpack module).

I used it as is, but it could be used as a constant as well (similar to how it is now in Kick):

  if (ENV === 'production') {
    // Enable for performance boost on production
    $compileProvider.debugInfoEnabled(false);

    // Disable console.log outputs for production
    $logProvider.debugEnabled(false);
  }

The main benefit is that we'd be using something that Webpack already provides and familiar to others.
1 less package to download.
No weird characters.

morsdyce added a commit that referenced this issue Nov 21, 2015
* master:
  use DefinePlugin to handle replacements for environments (closes #40)
  add missing utils module to fs-utils
  update angularsj version
  move fs-utils to separate module
  inherit webpack output to see errors in console

# Conflicts:
#	lib/utils.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant