Skip to content

Commit 8a10ca9

Browse files
committed
docs: add babel-loader example
Closes: #171
1 parent be9cd64 commit 8a10ca9

File tree

8 files changed

+91
-0
lines changed

8 files changed

+91
-0
lines changed

.DS_Store

0 Bytes
Binary file not shown.

examples/.DS_Store

6 KB
Binary file not shown.

examples/babel-loader/.babelrc.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
"presets": [
3+
"@babel/preset-env",
4+
"@babel/preset-typescript"
5+
]
6+
}

examples/babel-loader/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## babel-loader configuration example
2+
3+
It's a basic configuration of the plugin and [babel-loader](https://github.com/babel/babel-loader).
4+
Very similar to the [ts-loader example](../ts-loader), the main difference in the configuration is that we
5+
enable **syntactic diagnostics**:
6+
7+
```js
8+
new ForkTsCheckerWebpackPlugin({
9+
typescript: {
10+
diagnosticOptions: {
11+
semantic: true,
12+
syntactic: true,
13+
},
14+
},
15+
})
16+
```
17+

examples/babel-loader/package.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "fork-ts-checker-webpack-plugin-babel-loader-example",
3+
"version": "0.0.0",
4+
"main": "dist/index.js",
5+
"license": "MIT",
6+
"scripts": {
7+
"dev": "webpack-dev-server",
8+
"build": "webpack -p"
9+
},
10+
"devDependencies": {
11+
"@babel/core": "^7.6.0",
12+
"@babel/preset-env": "^7.6.0",
13+
"@babel/preset-typescript": "^7.6.0",
14+
"babel-loader": "^8.0.0",
15+
"fork-ts-checker-webpack-plugin": "^5.0.0-alpha.9",
16+
"typescript": "^3.8.0",
17+
"webpack": "^4.0.0",
18+
"webpack-cli": "^3.0.0",
19+
"webpack-dev-server": "^3.0.0"
20+
}
21+
}

examples/babel-loader/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log('Hello world');
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES5",
4+
"module": "CommonJS",
5+
"lib": ["ES5", "ScriptHost"],
6+
"moduleResolution": "Node",
7+
"esModuleInterop": true,
8+
"skipLibCheck": true,
9+
"skipDefaultLibCheck": true,
10+
"strict": true,
11+
"baseUrl": "./src",
12+
"outDir": "./dist",
13+
"forceConsistentCasingInFileNames": true,
14+
"importsNotUsedAsValues": "preserve" // this is important for proper files watching
15+
},
16+
"include": ["./src"],
17+
"exclude": ["node_modules"]
18+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
2+
3+
module.exports = {
4+
context: __dirname,
5+
entry: './src/index.ts',
6+
resolve: {
7+
extensions: ['.ts', '.tsx', '.js'],
8+
},
9+
module: {
10+
rules: [
11+
{
12+
test: /\.tsx?$/,
13+
loader: 'babel-loader',
14+
exclude: /node_modules/,
15+
},
16+
],
17+
},
18+
plugins: [
19+
new ForkTsCheckerWebpackPlugin({
20+
typescript: {
21+
diagnosticOptions: {
22+
semantic: true,
23+
syntactic: true,
24+
},
25+
},
26+
}),
27+
],
28+
};

0 commit comments

Comments
 (0)