Skip to content

Commit 34b9e44

Browse files
committed
- Initial commit with features:
- Typescript integration - Webpack builds for development and production - TSLint configured - Lodash integration for a simple startup sample - Typescript target set to ES5
0 parents  commit 34b9e44

File tree

12 files changed

+248
-0
lines changed

12 files changed

+248
-0
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Build results
2+
dist/
3+
typings/**/*
4+
5+
# Others
6+
~$*
7+
*~
8+
node_modules/

.vscode/launch.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Attach with sourcemaps",
6+
"type": "chrome",
7+
"request": "attach",
8+
"sourceMaps": true,
9+
"port": 9222,
10+
"diagnosticLogging": true,
11+
"webRoot": "${workspaceRoot}/dist"
12+
}
13+
]
14+
}

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Typescript Webpack Starter
2+
3+
A damn simple starter kit to bootstrap a Typescript/ES6
4+
## Build
5+
Build a development release
6+
```bash
7+
npm install
8+
npm run build
9+
```
10+
11+
Build a production release
12+
```bash
13+
npm install
14+
npm run build:prod
15+
```
16+
Bundled files are outputed to `dist` folder
17+
18+
## Debug
19+
20+
### Issues whith Chrome Debugger
21+
Sometimes Chrome debugger is not correctly initialized, as a consequence for VSCode to receive an access denied from Chrome on port 9222.
22+
23+
The workaround is to close all Chrome instances and run it manually enabling debugging port
24+
```bat
25+
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222
26+
```
27+
28+
## TODO
29+
30+
- [-] Add samples (Jquery integration)
31+
- [-] Add Webpack HTML Plugin to generate an index.html

config/webpack/webpack.dev.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
var path = require("path");
2+
var webpack = require("webpack");
3+
4+
var config = {
5+
6+
entry: {
7+
'vendor': './src/vendor.ts',
8+
'app': './src/index.ts'
9+
},
10+
debug: true,
11+
devtool: 'source-map',
12+
output: {
13+
path: path.resolve("dist"),
14+
filename: '[name].bundle.js',
15+
sourceMapFilename: '[name].map',
16+
devtoolModuleFilenameTemplate: function (info) {
17+
return "file:///" + info.absoluteResourcePath;
18+
}
19+
},
20+
tslint: {
21+
emitErrors: false,
22+
failOnHint: false,
23+
resourcePath: 'src'
24+
},
25+
resolve: {
26+
extensions: ["", ".ts", ".js"]
27+
},
28+
module: {
29+
preLoaders: [
30+
{ test: /\.ts$/, exclude: ["node_modules"], loader: "tslint" }
31+
],
32+
loaders: [
33+
{ test: /\.ts$/, exclude: ["node_modules"], loader: 'ts-loader' },
34+
{ test: /\.html$/, loader: "html" },
35+
{ test: /\.css$/, loader: "style-loader!css-loader" }
36+
]
37+
}
38+
};
39+
40+
module.exports = config;

config/webpack/webpack.prod.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
var path = require("path");
2+
var webpack = require("webpack");
3+
4+
var config = {
5+
6+
entry: {
7+
'vendor': './src/vendor.ts',
8+
'app': './src/index.ts'
9+
},
10+
debug: true,
11+
devtool: 'source-map',
12+
output: {
13+
path: path.resolve("dist"),
14+
filename: '[name].bundle.js',
15+
sourceMapFilename: '[name].map',
16+
devtoolModuleFilenameTemplate: function (info) {
17+
return "file:///" + info.absoluteResourcePath;
18+
}
19+
},
20+
tslint: {
21+
emitErrors: false,
22+
failOnHint: false,
23+
resourcePath: 'src'
24+
},
25+
resolve: {
26+
extensions: ["", ".ts", ".js"]
27+
},
28+
module: {
29+
preLoaders: [
30+
{ test: /\.ts$/, exclude: ["node_modules"], loader: "tslint" }
31+
],
32+
loaders: [
33+
{ test: /\.ts$/, exclude: ["node_modules"],loader: 'ts-loader' },
34+
{ test: /\.html$/, loader: "html" },
35+
{ test: /\.css$/, loader: "style-loader!css-loader" }
36+
]
37+
},
38+
plugins: [
39+
new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } }),
40+
]
41+
};
42+
43+
module.exports = config;

jsconfig.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
// See https://go.microsoft.com/fwlink/?LinkId=759670
3+
// for the documentation about the jsconfig.json format
4+
"compilerOptions": {
5+
"target": "es6",
6+
"module": "commonjs",
7+
"allowSyntheticDefaultImports": true
8+
},
9+
"exclude": [
10+
"node_modules",
11+
"bower_components",
12+
"jspm_packages",
13+
"tmp",
14+
"temp"
15+
]
16+
}

package.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "typescript-webpack-starter",
3+
"version": "0.0.1",
4+
"description": "A damn simple starter for Typescript and Webpack",
5+
"main": "src/index.ts",
6+
"scripts": {
7+
"rimraf": "rimraf",
8+
"webpack": "webpack",
9+
"build": "npm run build:dev",
10+
"prebuild:dev": "npm run rimraf -- dist",
11+
"build:dev": "webpack --config config/webpack/webpack.dev.js --progress --profile --colors --display-error-details --display-cached",
12+
"prebuild:prod": "npm run rimraf -- dist",
13+
"build:prod": "webpack --config config/webpack/webpack.prod.js --progress --profile --colors --display-error-details --display-cached --bail",
14+
"test": "echo \"Error: no test specified\" && exit 1",
15+
"postinstall": "typings i"
16+
},
17+
"repository": {
18+
"type": "git",
19+
"url": "https://github.com/emyann/typescript-webpack-starter"
20+
},
21+
"author": "yrenaudin",
22+
"license": "ISC",
23+
"devDependencies": {
24+
"css-loader": "^0.23.1",
25+
"expose-loader": "^0.7.1",
26+
"html-loader": "^0.4.3",
27+
"rimraf": "^2.5.4",
28+
"style-loader": "^0.13.1",
29+
"ts-loader": "^0.8.2",
30+
"tslint": "^3.13.0",
31+
"tslint-loader": "^2.1.5",
32+
"typescript": "^1.8.10",
33+
"typings": "^1.3.2",
34+
"webpack": "^1.13.1"
35+
},
36+
"dependencies": {
37+
"lodash":"^4.14.1"
38+
}
39+
}

src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export default class Main {
2+
constructor() {
3+
console.log('Typescript Webpack starter launched');
4+
}
5+
}

src/vendor.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Application Dependencies
2+
3+
import 'lodash';
4+

tsconfig.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"module": "commonjs",
5+
"sourceMap": true
6+
},
7+
"exclude": [
8+
"node_modules",
9+
"dist"
10+
]
11+
}

0 commit comments

Comments
 (0)