-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix] #26 Typescript導入 Vscode側で import Errorが起きる
- Loading branch information
1 parent
79d90b7
commit 91e32e9
Showing
11 changed files
with
100 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
declare module "react"; | ||
declare module "react-dom"; | ||
declare module "react/jsx-runtime" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import * as _ from 'lodash'; | ||
|
||
function component() { | ||
const element = document.createElement('div'); | ||
|
||
element.innerHTML = _.join(['Hello', 'webpack'], ' '); | ||
console.log(element); | ||
return element; | ||
} | ||
|
||
document.body.appendChild(component()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"compilerOptions": { | ||
"outDir": "./dist/", | ||
"noImplicitAny": true, | ||
"module": "es6", | ||
"target": "es5", | ||
"jsx": "react", | ||
"allowJs": true, | ||
"moduleResolution": "node", | ||
"types": [ | ||
"node" | ||
], | ||
"allowSyntheticDefaultImports": true, | ||
"esModuleInterop": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
module.exports = { | ||
// モード値を production に設定すると最適化された状態で、 | ||
// development に設定するとソースマップ有効でJSファイルが出力される | ||
mode: "development", | ||
|
||
// メインとなるJavaScriptファイル(エントリーポイント) | ||
entry: { | ||
main: { | ||
import: './src/frontend/ts/test.tsx', | ||
dependOn: 'shared' | ||
}, | ||
shared: ['lodash'] | ||
}, | ||
// ファイルの出力設定 | ||
output: { | ||
// 出力ファイルのディレクトリ名 | ||
path: `${__dirname}/dist`, | ||
// 出力ファイル名 | ||
filename: "[name].js", | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
// 拡張子 .ts もしくは .tsx の場合 | ||
test: /\.tsx?$/, | ||
// TypeScript をコンパイルする | ||
use: "ts-loader", | ||
exclude: /node_modules/ | ||
}, | ||
], | ||
}, | ||
// import 文で .ts や .tsx ファイルを解決するため | ||
resolve: { | ||
extensions: [".ts", ".tsx", ".js", ".json"], | ||
}, | ||
// ES5(IE11等)向けの指定 | ||
target: ["web", "es5"], | ||
devServer: { | ||
static: { | ||
directory: `${__dirname}/dist` | ||
} | ||
}, | ||
}; |