diff --git a/README.md b/README.md index 8a4b73be4..e227aa6ae 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ in which case you may not even need the asset pipeline. This is mostly relevant - [Installation](#installation) - [Usage](#usage) - [Development](#development) + - [Webpack configuration](#webpack-configuration) - [Integrations](#integrations) - [React](#react) - [Angular with TypeScript](#angular-with-typescript) @@ -173,6 +174,10 @@ when running `./bin/webpack-dev-server` binstub: **Note:** Don't forget to prefix `ruby` when running these binstubs on windows +### Webpack configuration + +See [docs/Webpack](docs/webpack.md) for modifying webpack configuration and loaders. + ## Integrations Webpacker ships with basic out-of-the-box integration for React, Angular, Vue and Elm. diff --git a/docs/webpack.md b/docs/webpack.md index b6d13be52..57bc369a4 100644 --- a/docs/webpack.md +++ b/docs/webpack.md @@ -8,7 +8,7 @@ production environments in `config/webpack/*.js`. You can configure each individ environment in their respective files or configure them all in the base `config/webpack/environment.js` file. -By default, you shouldn't have to make any changes to `config/webpack/*.js` +By default, you don't need to make any changes to `config/webpack/*.js` files since it's all standard production-ready configuration. However, if you do need to customize or add a new loader, this is where you would go. @@ -36,6 +36,14 @@ const customConfig = require('./custom') module.exports = merge(environment.toWebpackConfig(), customConfig) ``` +If you need access to configs within Webpacker's configuration, you can import them like this: +```js +const config = require('@rails/webpacker/package/config'); +const asset_host = require('@rails/webpacker/package/asset_host'); + +console.log(asset_host.publicPathWithHost); +``` + **Note:** You will have to merge custom config to all env where you want that config to be available. In above case, it will be applied to development environment.