Skip to content

Update documentation with how to change config in the top level readm… #846

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

Merged
merged 7 commits into from
Sep 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down
10 changes: 9 additions & 1 deletion docs/webpack.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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.

Expand Down