Skip to content

Commit c1909fb

Browse files
committed
First commit
1 parent a8c579b commit c1909fb

File tree

6 files changed

+2709
-0
lines changed

6 files changed

+2709
-0
lines changed

.eslintrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": ["standard", "prettier"],
3+
"plugins": ["prettier"],
4+
"rules": {
5+
"prettier/prettier": "error"
6+
}
7+
}

.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"eslintIntegration": true,
3+
"semi": false,
4+
"singleQuote": true
5+
}

.vscode/settings.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
// Always auto-format if possible on save.
3+
"editor.formatOnSave": true,
4+
5+
// Enable auto-formatting for these languages.
6+
"javascript.format.enable": true,
7+
8+
// Use `prettier-eslint` instead of just `prettier`. This automatically pulls
9+
// in `eslint` settings and parsing.
10+
"prettier.eslintIntegration": true,
11+
12+
// Exclude these folders from default searches.
13+
"search.exclude": {
14+
"**/node_modules": true
15+
}
16+
}

index.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const path = require('path')
2+
const { getLoader, getBabelLoader } = require('react-app-rewired')
3+
4+
function rewireTypescript(config, env, typescriptLoaderOptions = {}) {
5+
const typescriptExtension = /\.tsx?$/
6+
7+
const fileLoader = getLoader(
8+
config.module.rules,
9+
rule =>
10+
rule.loader &&
11+
typeof rule.loader === 'string' &&
12+
rule.loader.endsWith(`file-loader${path.sep}index.js`)
13+
)
14+
fileLoader.exclude.push(typescriptExtension)
15+
16+
const babelRules = getBabelLoader(config.module.rules)
17+
18+
const typescriptRules = {
19+
test: typescriptExtension,
20+
use: [
21+
...babelRules.use,
22+
{ loader: 'ts-loader', options: typescriptLoaderOptions }
23+
]
24+
}
25+
26+
config.module.rules.push(typescriptRules)
27+
28+
return config
29+
}
30+
31+
module.exports = rewireTypescript

0 commit comments

Comments
 (0)