Skip to content

docs(config) add comments and values for rule.type #2541

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 3 commits into from
Sep 27, 2018
Merged
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
24 changes: 24 additions & 0 deletions src/content/configuration/module.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ contributors:
- byzyk
- pnevares
- fadysamirsadek
- nerdkid93
---

These options determine how the [different types of modules](/concepts/modules) within a project will be treated.
Expand Down Expand Up @@ -264,6 +265,29 @@ Indicate what parts of the module contain side effects. See [Tree Shaking](/guid
`Rule.test` is a shortcut to `Rule.resource.test`. If you supply a `Rule.test` option, you cannot also supply a `Rule.resource`. See [`Rule.resource`](#rule-resource) and [`Condition.test`](#condition) for details.


## `Rule.type`

Possible values: `"javascript/auto" | "javascript/dynamic" | "javascript/esm" | "json" | "webassembly/experimental"`

`Rule.type` sets the type for a matching module. This prevents defaultRules and their default importing behaviors from occurring. For example, if you want to load a `.json` file through a custom loader, you'd need to set the `type` to `javascript/auto` to bypass webpack's built-in json importing. (See [v4.0 changelog](https://github.com/webpack/webpack/releases/tag/v4.0.0) for more details)

```javascript
module.exports = {
//...
module: {
rules: [
//...
{
test: /\.json$/,
type: 'javascript/auto',
loader: 'custom-json-loader'
}
]
}
};
```


## `Rule.use`

A list of [UseEntries](#useentry) which are applied to modules. Each entry specifies a loader to be used.
Expand Down