Skip to content

Commit

Permalink
add ts-loader "vanilla" example
Browse files Browse the repository at this point in the history
  • Loading branch information
ath0mas committed Oct 14, 2020
1 parent 9e7e855 commit 62eaefc
Show file tree
Hide file tree
Showing 9 changed files with 3,433 additions and 0 deletions.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ webpack.config.js
/.vscode
/.gitignore
/node_modules
/example
.github/
.idea/
*.iml
Expand Down
13 changes: 13 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# vanilla ts-loader

```shell
yarn install

# Run in watch mode
yarn watch

# Run in production mode
yarn build
```

To see your output simply open up the `index.html` file in your browser of choice.
11 changes: 11 additions & 0 deletions example/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<div id="wrapper"></div>

<script src="dist/main.js"></script>
</body>
</html>
16 changes: 16 additions & 0 deletions example/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "vanilla",
"main": "index.js",
"version": "1.0.0",
"scripts": {
"build": "webpack --mode production",
"start": "webpack-dev-server --mode development --progress --color"
},
"devDependencies": {
"ts-loader": "^5.0.0",
"typescript": "^3.0.0",
"webpack": "^4.0.0",
"webpack-cli": "^3.0.0",
"webpack-dev-server": "^3.1.14"
}
}
3 changes: 3 additions & 0 deletions example/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import render = require('./render');

render();
5 changes: 5 additions & 0 deletions example/src/render.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function render() {
document.getElementById('wrapper').innerHTML = "<h1> Hello World!</h1>";
}

export = render;
5 changes: 5 additions & 0 deletions example/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"compilerOptions": {
"sourceMap": true
}
}
22 changes: 22 additions & 0 deletions example/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';
const path = require('path');

module.exports = {
devtool: 'inline-source-map',
entry: './src/index.ts',
output: {
filename: 'main.js',
path: path.resolve(__dirname, 'dist')
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader'
}
]
},
resolve: {
extensions: [ '.ts', '.tsx', '.js' ]
}
};
Loading

0 comments on commit 62eaefc

Please sign in to comment.