-
-
Notifications
You must be signed in to change notification settings - Fork 199
Add various methods to configure default plugins #152
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,14 +102,90 @@ const publicApi = { | |
return this; | ||
}, | ||
|
||
/** | ||
* Allows you to configure the options passed to the DefinePlugin. | ||
* A list of available options can be found at https://webpack.js.org/plugins/define-plugin/ | ||
* | ||
* For example: | ||
* | ||
* Encore.configureDefinePlugin((options) => { | ||
* options.VERSION = JSON.stringify('1.0.0'); | ||
* }) | ||
* | ||
* @param {function} definePluginOptionsCallback | ||
* @returns {exports} | ||
*/ | ||
configureDefinePlugin(definePluginOptionsCallback = () => {}) { | ||
webpackConfig.configureDefinePlugin(definePluginOptionsCallback); | ||
|
||
return this; | ||
}, | ||
|
||
/** | ||
* Allows you to configure the options passed to the extract-text-webpack-plugin. | ||
* A list of available options can be found at https://github.com/webpack-contrib/extract-text-webpack-plugin | ||
* | ||
* For example: | ||
* | ||
* Encore.configureExtractTextPlugin((options) => { | ||
* options.ignoreOrder = true; | ||
* }) | ||
* | ||
* @param {function} extractTextPluginOptionsCallback | ||
* @returns {exports} | ||
*/ | ||
configureExtractTextPlugin(extractTextPluginOptionsCallback = () => {}) { | ||
webpackConfig.configureExtractTextPlugin(extractTextPluginOptionsCallback); | ||
|
||
return this; | ||
}, | ||
|
||
/** | ||
* Allows you to configure the options passed to the friendly-errors-webpack-plugin. | ||
* A list of available options can be found at https://github.com/geowarin/friendly-errors-webpack-plugin | ||
* | ||
* For example: | ||
* | ||
* Encore.configureFriendlyErrorsPlugin((options) => { | ||
* options.clearConsole = true; | ||
* }) | ||
* | ||
* @param {function} friendlyErrorsPluginOptionsCallback | ||
* @returns {exports} | ||
*/ | ||
configureFriendlyErrorsPlugin(friendlyErrorsPluginOptionsCallback = () => {}) { | ||
webpackConfig.configureFriendlyErrorsPlugin(friendlyErrorsPluginOptionsCallback); | ||
|
||
return this; | ||
}, | ||
|
||
/** | ||
* Allows you to configure the options passed to the LoaderOptionsPlugins. | ||
* A list of available options can be found at https://webpack.js.org/plugins/loader-options-plugin/ | ||
* | ||
* For example: | ||
* | ||
* Encore.configureLoaderOptionsPlugin((options) => { | ||
* options.minimize = true; | ||
* }) | ||
* | ||
* @param {function} loaderOptionsPluginOptionsCallback | ||
* @returns {exports} | ||
*/ | ||
configureLoaderOptionsPlugin(loaderOptionsPluginOptionsCallback = () => {}) { | ||
webpackConfig.configureLoaderOptionsPlugin(loaderOptionsPluginOptionsCallback); | ||
|
||
return this; | ||
}, | ||
|
||
/** | ||
* Allows you to configure the options passed to webpack-manifest-plugin. | ||
* A list of available options can be found at https://github.com/danethurber/webpack-manifest-plugin | ||
* | ||
* For example: | ||
* | ||
* Encore.configureManifestPlugin(function(options){ | ||
* options.fileName: '../../var/assets/manifest.json' | ||
* Encore.configureManifestPlugin((options) => { | ||
* options.fileName = '../../var/assets/manifest.json'; | ||
* }) | ||
* | ||
* @param {function} manifestPluginOptionsCallback | ||
|
@@ -121,6 +197,26 @@ const publicApi = { | |
return this; | ||
}, | ||
|
||
/** | ||
* Allows you to configure the options passed to the uglifyjs-webpack-plugin. | ||
* A list of available options can be found at https://github.com/webpack-contrib/uglifyjs-webpack-plugin/tree/v0.4.6 | ||
* | ||
* For example: | ||
* | ||
* Encore.configureUglifyJsPlugin((options) => { | ||
* options.compress = false; | ||
* options.beautify = true; | ||
* }) | ||
* | ||
* @param {function} uglifyJsPluginOptionsCallback | ||
* @returns {exports} | ||
*/ | ||
configureUglifyJsPlugin(uglifyJsPluginOptionsCallback = () => {}) { | ||
webpackConfig.configureUglifyJsPlugin(uglifyJsPluginOptionsCallback); | ||
|
||
return this; | ||
}, | ||
|
||
/** | ||
* Adds a JavaScript file that should be webpacked: | ||
* | ||
|
@@ -519,13 +615,22 @@ const publicApi = { | |
}, | ||
|
||
/** | ||
* If enabled, the output directory is emptied between | ||
* each build (to remove old files). | ||
* If enabled, the output directory is emptied between each build (to remove old files). | ||
* | ||
* A list of available options can be found at https://github.com/johnagan/clean-webpack-plugin | ||
* | ||
* For example: | ||
* | ||
* Encore.cleanupOutputBeforeBuild(['*.js'], (options) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should show the default There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wanted to but There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ha! What a crazy edge case :p |
||
* options.dry = true; | ||
* }) | ||
* | ||
* @param {Array} paths Paths that should be cleaned, relative to the "root" option | ||
* @param {function} cleanWebpackPluginOptionsCallback | ||
* @returns {exports} | ||
*/ | ||
cleanupOutputBeforeBuild() { | ||
webpackConfig.cleanupOutputBeforeBuild(); | ||
cleanupOutputBeforeBuild(paths = ['**/*'], cleanWebpackPluginOptionsCallback = () => {}) { | ||
webpackConfig.cleanupOutputBeforeBuild(paths, cleanWebpackPluginOptionsCallback); | ||
|
||
return this; | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all looks beautiful