add typescript for webpack

This commit is contained in:
Krylov Sergey 2022-06-07 13:28:53 +05:00
parent a42049a4cd
commit 6b28570095
8 changed files with 2894 additions and 0 deletions

View File

@ -0,0 +1,32 @@
/*
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
* This devtool is neither made for production nor for readable output files.
* It uses "eval()" calls to create a separate source file in the browser devtools.
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
* or disable the default devtool with "devtool: false".
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
*/
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ "./index.ts":
/*!******************!*\
!*** ./index.ts ***!
\******************/
/***/ (() => {
eval("console.log('Webpack with typescript');\n\n//# sourceURL=webpack:///./index.ts?");
/***/ })
/******/ });
/************************************************************************/
/******/
/******/ // startup
/******/ // Load entry module and return exports
/******/ // This entry module can't be inlined because the eval devtool is used.
/******/ var __webpack_exports__ = {};
/******/ __webpack_modules__["./index.ts"]();
/******/
/******/ })()
;

2810
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

14
package.json Normal file
View File

@ -0,0 +1,14 @@
{
"devDependencies": {
"@types/node": "^17.0.40",
"@types/webpack": "^5.28.0",
"cross-env": "^7.0.3",
"ts-node": "^10.8.1",
"tsconfig-paths": "^4.0.0",
"typescript": "^4.7.3",
"webpack-cli": "^4.9.2"
},
"scripts": {
"build": "cross-env TS_NODE_PROJECT=\"tsconfig-for-webpack-config.json\" webpack --mode=development"
}
}

1
src/index.ts Normal file
View File

@ -0,0 +1 @@
console.log('Webpack with typescript');

View File

@ -0,0 +1,7 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"esModuleInterop": true
}
}

15
tsconfig.json Normal file
View File

@ -0,0 +1,15 @@
{
"compilerOptions": {
"outDir": "./dist/",
"noImplicitAny": true,
"target": "es5",
"jsx": "react",
"allowJs": true,
"moduleResolution": "node"
},
"ts-node": {
"compilerOptions": {
"module": "CommonJS"
}
}
}

View File

15
webpack.config.ts Normal file
View File

@ -0,0 +1,15 @@
import * as path from 'path';
import * as webpack from 'webpack';
// in case you run into any typescript error when configuring `devServer`
// import 'webpack-dev-server';
const config: webpack.Configuration = {
context: path.resolve(__dirname, 'src'),
entry: './index.ts',
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name]-[hash].bundle.js',
},
};
export default config;