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

Warn about webpack loaders #638

Merged
merged 1 commit into from Jan 3, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Expand Up @@ -483,23 +483,23 @@ module.exports = {

In order to extend our usage of `webpack`, you can define a function that extends its config via `next.config.js`.

The following example shows how you can use [`react-svg-loader`](https://github.com/boopathi/react-svg-loader) to easily import any `.svg` file as a React component, without modification.

```js
// This file is not going through babel transformation.
// So, we write it in vanilla JS
// (But you could use ES2015 features supported by your Node.js version)

module.exports = {
webpack: (config, { dev }) => {
config.module.rules.push({ test: /\.svg$/, loader: 'babel!react-svg' })

// Important: return the modified config
   // Perform customizations to config
   
   // Important: return the modified config
return config
}
}
```

*Warning: Adding loaders to support new file types (css, less, svg, etc.) is __not__ recommended because only the client code gets bundled via webpack and thus it won't work on the initial server rendering. Babel plugins are a good alternative because they're applied consistently between server/client rendering (e.g. [babel-plugin-inline-react-svg](https://github.com/kesne/babel-plugin-inline-react-svg)).*

### Customizing babel config

In order to extend our usage of `babel`, you can simply define a `.babelrc` file at the root of your app. This file is optional.
Expand Down