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

How can the default production environment be customized? #771

Closed
caselas opened this issue Sep 7, 2017 · 3 comments
Closed

How can the default production environment be customized? #771

caselas opened this issue Sep 7, 2017 · 3 comments

Comments

@caselas
Copy link

caselas commented Sep 7, 2017

I apologize if this is documented somewhere, but I was unable to find it.

What is the correct approach to remove/replace, for example, the UglifyJs plugin in the webpack config for production? I would like to use uglify-es as a replacement for uglify-js.

This was simple to do before 3.x due to the config existing within my application, but now that it's been abstracted into an internal default config, I'm not sure how to modify it.

Thanks!

@gauravtiwari
Copy link
Member

You can delete the Uglify plugin from the plugins Map (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/delete) and add the one you need. Please see the documentation here on how to add a plugin. https://github.com/rails/webpacker/blob/master/docs/webpack.md

@caselas
Copy link
Author

caselas commented Sep 7, 2017

Thanks, I missed that somehow.

The solution is quite simple:

// config/webpack/production.js
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const environment = require('./environment')

environment.plugins.delete('UglifyJs')

environment.plugins.set(
  'UglifyJs',
  new UglifyJsPlugin({
    sourceMap: true
  })
)

module.exports = environment.toWebpackConfig()

@caselas caselas closed this as completed Sep 7, 2017
@gauravtiwari
Copy link
Member

Awesome, thanks for sharing 🍰 👍

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

2 participants