Skip to content
43 changes: 43 additions & 0 deletions src/content/configuration/configuration-languages.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ contributors:
- tarang9211
- simon04
- peterblazejewicz
- youta1119
---

webpack accepts configuration files written in multiple programming and data languages. The list of supported file extensions can be found at the [node-interpret](https://github.com/js-cli/js-interpret) package. Using [node-interpret](https://github.com/js-cli/js-interpret), webpack can handle many different types of configuration files.
Expand Down Expand Up @@ -39,6 +40,48 @@ const config: webpack.Configuration = {
export default config;
```

Not that you'll also need to check your `tsconfig.json` file. If the module in `compilerOptions` in `tsconfig.json` is `commonjs`, the setting is complete, else webpack will fail with an error. This occurs because `ts-node` does not support any module syntax other than `commonjs`.

There are two solutions to this issue:

- Modify `tsconfig.json`.
- Install `tsconfig-paths`.

The __first option__ is to open your `tsconfig.json` file and look for `compilerOptions`. Set `target` to `"ES5"` and `module` to `"CommonJS"` (or completely remove the `module` option).

The __second option__ is to install the `tsconfig-paths` package:

``` bash
npm install --save-dev tsconfig-paths
```

And create a separate TypeScript configuration specifically for your webpack configs:

__tsconfig-for-webpack-config.json__

``` json
{
"compilerOptions": {
"module": "commonjs",
"target": "es5"
}
}
```

T> `ts-node` can resolve a `tsconfig.json` file using the environment variable provided by `tsconfig-path`.

Then set the environment variable `process.env.TS_NODE_PROJECT` provided by `tsconfig-path` like so:

__package.json__

```json
{
"scripts": {
"build": "TS_NODE_PROJECT=\"tsconfig-for-webpack-config.json\" webpack"
}
}
```


## CoffeeScript

Expand Down