Skip to content

Commit 6a15fd2

Browse files
authored
Merge pull request #638 from jkovzels/patch-1
Adding resolve.extentions to configuration sample
2 parents 7da0bd7 + 67b6616 commit 6a15fd2

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

content/guides/webpack-and-typescript.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,18 @@ module.exports = {
5757
test: /\.tsx?$/,
5858
loader: 'ts-loader',
5959
exclude: /node_modules/,
60-
}
60+
},
6161
]
62-
}
62+
},
63+
resolve: {
64+
extensions: [".tsx", ".ts", ".js"]
65+
},
6366
};
6467
```
6568

6669
Here we specify our entry point to be __index.ts__ in our current directory,
6770
an output file called __bundle.js__
68-
and our TypeScript loader that is in charge of compiling our TypeScript file to JavaScript.
71+
and our TypeScript loader that is in charge of compiling our TypeScript file to JavaScript. We also add `resolve.extensions` to instruct webpack what file extensions to use when resolving Typescript modules.
6972

7073
## Typescript loaders
7174

@@ -111,8 +114,16 @@ module.exports = {
111114
test: /\.js$/,
112115
loader: "source-map-loader"
113116
},
117+
{
118+
enforce: 'pre',
119+
test: /\.js$/,
120+
use: "source-map-loader"
121+
}
114122
]
115123
},
124+
resolve: {
125+
extensions: [".tsx", ".ts", ".js"]
126+
},
116127
devtool: 'inline-source-map',
117128
};
118129
```
@@ -163,4 +174,4 @@ Here we declare a new module for svg by specifying any import that ends in __.sv
163174
If we wanted to be more explicit about this being a url we could define the type as string.
164175

165176
This applies not only to svg but any custom loader you may want to use which includes css, scss, json or any other file you may wish to load in your project.
166-
177+

0 commit comments

Comments
 (0)