Skip to content

Commit 3309bb3

Browse files
committed
Merge branch 'feature/Migrate_Typescript_Webpack' into develop
2 parents 1f322f0 + 8a9125d commit 3309bb3

File tree

7 files changed

+82
-54
lines changed

7 files changed

+82
-54
lines changed

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Typescript Webpack Starter
22
>A damn simple ES6 and Typescript Starter kit using webpack for packaging. Perfect for bootstraping your javascript project regardless any framework.
33
4+
## Built upon
5+
6+
- [x] [Webpack 2](https://webpack.github.io/docs/roadmap.html#2)
7+
- [x] [Typescript 2](https://blogs.msdn.microsoft.com/typescript/2016/07/11/announcing-typescript-2-0-beta/)
8+
49
# Getting started
510

611
## Clone Typescript Webpack Starter
@@ -21,10 +26,13 @@ Build a production release
2126
npm install
2227
npm run build:prod
2328
```
24-
Bundled files are releases into `dist` folder
29+
After build phase, those files are generated into the `dist` folder:
30+
- `app.bundle.js` - contains the core of the application. From the entry point `src/index.ts`
31+
- `vendor.bundle.js` - contains the ve
2532

2633
## TODO
2734

2835
- [-] Add samples (Jquery integration for example..)
2936
- [-] Setup a webpack-dev-server
30-
- [-] Setup VSCode debuug to match webpack-dev-server
37+
- [-] Setup VSCode debuug to match webpack-dev-server
38+
- [-] Setup a webpack common configuration and use webpack-merge

config/webpack/webpack.dev.js

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,56 @@
1-
var path = require("path");
2-
var webpack = require("webpack");
3-
var HtmlWebpackPlugin = require('html-webpack-plugin');
1+
const webpack = require('webpack');
2+
const path = require('path');
3+
const HtmlWebpackPlugin = require('html-webpack-plugin');
44

55
var config = {
6-
6+
devtool: 'cheap-eval-source-map',
7+
context: path.resolve('./src'),
78
entry: {
8-
'vendor': './src/vendor.ts',
9-
'app': './src/index.ts'
9+
app: './index.ts',
10+
vendor: './vendor.ts'
1011
},
11-
debug: true,
12-
devtool: 'source-map',
1312
output: {
14-
path: path.resolve("dist"),
13+
path: path.resolve('./dist'),
1514
filename: '[name].bundle.js',
1615
sourceMapFilename: '[name].map',
1716
devtoolModuleFilenameTemplate: function (info) {
1817
return "file:///" + info.absoluteResourcePath;
1918
}
2019
},
21-
tslint: {
22-
emitErrors: false,
23-
failOnHint: false,
24-
resourcePath: 'src'
25-
},
26-
resolve: {
27-
extensions: ["", ".ts", ".js"]
28-
},
2920
module: {
3021
preLoaders: [
3122
{ test: /\.ts$/, exclude: ["node_modules"], loader: "tslint" }
3223
],
3324
loaders: [
3425
{ test: /\.ts$/, exclude: ["node_modules"], loader: 'ts-loader' },
3526
{ test: /\.html$/, loader: "html" },
36-
{ test: /\.css$/, loader: "style-loader!css-loader" }
27+
{ test: /\.css$/, loaders: ['style', 'css'] }
3728
]
3829
},
30+
resolve: {
31+
extensions: ["", ".ts", ".js"],
32+
modules: [path.resolve('./src'), 'node_modules']
33+
},
3934
plugins: [
4035
new HtmlWebpackPlugin({
4136
title: 'Typescript Webpack Starter',
4237
template: '!!ejs-loader!src/index.html'
43-
})
44-
]
38+
}),
39+
new webpack.optimize.CommonsChunkPlugin({
40+
name: 'vendor',
41+
minChunks: Infinity,
42+
filename: 'vendor.bundle.js'
43+
}),
44+
new webpack.optimize.UglifyJsPlugin({
45+
compress: {warnings: false},
46+
output: {comments: false},
47+
sourceMap: false
48+
}),
49+
],
50+
tslint: {
51+
emitErrors: false,
52+
failOnHint: false
53+
},
4554
};
4655

4756
module.exports = config;

config/webpack/webpack.prod.js

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,56 @@
1-
var path = require("path");
2-
var webpack = require("webpack");
3-
var HtmlWebpackPlugin = require('html-webpack-plugin');
1+
const webpack = require('webpack');
2+
const path = require('path');
3+
const HtmlWebpackPlugin = require('html-webpack-plugin');
44

55
var config = {
6-
6+
devtool: 'source-map',
7+
context: path.resolve('./src'),
78
entry: {
8-
'vendor': './src/vendor.ts',
9-
'app': './src/index.ts'
9+
app: './index.ts',
10+
vendor: './vendor.ts'
1011
},
11-
debug: true,
12-
devtool: 'source-map',
1312
output: {
14-
path: path.resolve("dist"),
13+
path: path.resolve('./dist'),
1514
filename: '[name].bundle.js',
1615
sourceMapFilename: '[name].map',
1716
devtoolModuleFilenameTemplate: function (info) {
1817
return "file:///" + info.absoluteResourcePath;
1918
}
2019
},
21-
tslint: {
22-
emitErrors: false,
23-
failOnHint: false,
24-
resourcePath: 'src'
25-
},
26-
resolve: {
27-
extensions: ["", ".ts", ".js"]
28-
},
2920
module: {
3021
preLoaders: [
3122
{ test: /\.ts$/, exclude: ["node_modules"], loader: "tslint" }
3223
],
3324
loaders: [
34-
{ test: /\.ts$/, exclude: ["node_modules"],loader: 'ts-loader' },
25+
{ test: /\.ts$/, exclude: ["node_modules"], loader: 'ts-loader' },
3526
{ test: /\.html$/, loader: "html" },
36-
{ test: /\.css$/, loader: "style-loader!css-loader" }
27+
{ test: /\.css$/, loaders: ['style', 'css'] }
3728
]
3829
},
30+
resolve: {
31+
extensions: ["", ".ts", ".js"],
32+
modules: [path.resolve('./src'), 'node_modules']
33+
},
3934
plugins: [
40-
new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } }),
41-
new HtmlWebpackPlugin({title: 'Typescript Webpack Starter'})
42-
]
35+
new HtmlWebpackPlugin({
36+
title: 'Typescript Webpack Starter',
37+
template: '!!ejs-loader!src/index.html'
38+
}),
39+
new webpack.optimize.CommonsChunkPlugin({
40+
name: 'vendor',
41+
minChunks: Infinity,
42+
filename: 'vendor.bundle.js'
43+
}),
44+
new webpack.optimize.UglifyJsPlugin({
45+
compress: { warnings: false },
46+
output: { comments: false },
47+
sourceMap: true
48+
}),
49+
],
50+
tslint: {
51+
emitErrors: false,
52+
failOnHint: false
53+
},
4354
};
4455

4556
module.exports = config;

jsconfig.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
},
99
"exclude": [
1010
"node_modules",
11-
"bower_components",
12-
"jspm_packages",
13-
"tmp",
14-
"temp"
11+
"dist"
1512
]
1613
}

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
"webpack": "webpack",
99
"build": "npm run build:dev",
1010
"prebuild:dev": "npm run rimraf -- dist",
11-
"build:dev": "webpack --config config/webpack/webpack.dev.js --progress --profile --colors --display-error-details --display-cached",
11+
"build:dev": "webpack --config config/webpack/webpack.dev.js --progress --profile --color --display-error-details --display-cached",
1212
"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",
13+
"build:prod": "webpack --config config/webpack/webpack.prod.js --progress --profile --color --display-error-details --display-cached --bail",
1414
"test": "echo \"Error: no test specified\" && exit 1",
1515
"postinstall": "typings i"
1616
},
@@ -31,9 +31,9 @@
3131
"ts-loader": "^0.8.2",
3232
"tslint": "^3.13.0",
3333
"tslint-loader": "^2.1.5",
34-
"typescript": "^1.8.10",
34+
"typescript": "^2.0.0",
3535
"typings": "^1.3.2",
36-
"webpack": "^1.13.1"
36+
"webpack": "^2.1.0-beta.20"
3737
},
3838
"dependencies": {
3939
"lodash": "^4.14.1"

src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ export default class Main {
22
constructor() {
33
console.log('Typescript Webpack starter launched');
44
}
5-
}
5+
}
6+
7+
let start = new Main();

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"compilerOptions": {
33
"target": "es5",
4-
"module": "commonjs",
4+
"module": "es6",
5+
"moduleResolution": "node",
56
"sourceMap": true
67
},
78
"exclude": [

0 commit comments

Comments
 (0)