Skip to content

Commit

Permalink
docs: add babel-loader example
Browse files Browse the repository at this point in the history
Closes: #171
  • Loading branch information
piotr-oles committed May 27, 2020
1 parent be9cd64 commit 8a10ca9
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 0 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file added examples/.DS_Store
Binary file not shown.
6 changes: 6 additions & 0 deletions examples/babel-loader/.babelrc.js
@@ -0,0 +1,6 @@
module.exports = {
"presets": [
"@babel/preset-env",
"@babel/preset-typescript"
]
}
17 changes: 17 additions & 0 deletions examples/babel-loader/README.md
@@ -0,0 +1,17 @@
## babel-loader configuration example

It's a basic configuration of the plugin and [babel-loader](https://github.com/babel/babel-loader).
Very similar to the [ts-loader example](../ts-loader), the main difference in the configuration is that we
enable **syntactic diagnostics**:

```js
new ForkTsCheckerWebpackPlugin({
typescript: {
diagnosticOptions: {
semantic: true,
syntactic: true,
},
},
})
```

21 changes: 21 additions & 0 deletions examples/babel-loader/package.json
@@ -0,0 +1,21 @@
{
"name": "fork-ts-checker-webpack-plugin-babel-loader-example",
"version": "0.0.0",
"main": "dist/index.js",
"license": "MIT",
"scripts": {
"dev": "webpack-dev-server",
"build": "webpack -p"
},
"devDependencies": {
"@babel/core": "^7.6.0",
"@babel/preset-env": "^7.6.0",
"@babel/preset-typescript": "^7.6.0",
"babel-loader": "^8.0.0",
"fork-ts-checker-webpack-plugin": "^5.0.0-alpha.9",
"typescript": "^3.8.0",
"webpack": "^4.0.0",
"webpack-cli": "^3.0.0",
"webpack-dev-server": "^3.0.0"
}
}
1 change: 1 addition & 0 deletions examples/babel-loader/src/index.ts
@@ -0,0 +1 @@
console.log('Hello world');
18 changes: 18 additions & 0 deletions examples/babel-loader/tsconfig.json
@@ -0,0 +1,18 @@
{
"compilerOptions": {
"target": "ES5",
"module": "CommonJS",
"lib": ["ES5", "ScriptHost"],
"moduleResolution": "Node",
"esModuleInterop": true,
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"strict": true,
"baseUrl": "./src",
"outDir": "./dist",
"forceConsistentCasingInFileNames": true,
"importsNotUsedAsValues": "preserve" // this is important for proper files watching
},
"include": ["./src"],
"exclude": ["node_modules"]
}
28 changes: 28 additions & 0 deletions examples/babel-loader/webpack.config.js
@@ -0,0 +1,28 @@
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');

module.exports = {
context: __dirname,
entry: './src/index.ts',
resolve: {
extensions: ['.ts', '.tsx', '.js'],
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
},
],
},
plugins: [
new ForkTsCheckerWebpackPlugin({
typescript: {
diagnosticOptions: {
semantic: true,
syntactic: true,
},
},
}),
],
};

0 comments on commit 8a10ca9

Please sign in to comment.