Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
TypeScript Geliştirme Ortamı Hazırlama
import { Person } from "./class";
let kisi:Person = new Person("Hasan","KÖROĞLU");
kisi.displayName();
export class Person {
name:string;
lastname:string;
constructor(_name:string,_lastname:string) {
this.name = _name;
this.lastname = _lastname;
}
displayName = () => document.write(`Hello, my name is ${this.name} ${this.lastname}`);
}
│ index.html
│ package.json
│ tsconfig.json
│ webpack.config.js
├───dist
└───src
├───app.ts
└───class.ts
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script src="./dist/bundle.js"></script>
</body>
</html>
{
"name": "typescript_webpack_ts-loader_example",
"version": "1.0.0",
"main": "./dist/bundle.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"web": "webpack-dev-server",
"bundle": "webpack"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"ts-loader": "^5.3.3",
"typescript": "^3.4.4",
"uglifyjs-webpack-plugin": "^2.1.2",
"webpack": "^4.30.0",
"webpack-cli": "^3.3.0",
"webpack-dev-server": "^3.3.1"
},
"dependencies": {},
"description": "TypeScript ile beraber webpack ve ts kodlarının webpack için bundle edilmesini sağlayan ts-loader örneği"
}
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"sourceMap": true,
"outDir": "./dist/",
"noImplicitAny": true
},
"exclude": [
"node_modules"
],
"include": [
"./src/*"
]
}
const path = require('path');
module.exports = {
entry: './src/app.ts',
devtool: 'inline-source-map',
mode: 'production',
module: {
rules: [
{
test: /\.ts/,
use: ['ts-loader'],
exclude: /node_modules/
}
]
},
resolve: {
extensions: [ '.ts', '.tsx', ".js", ".json"]
},
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.