Skip to content

Commit 8a9125d

Browse files
committed
- update webpack configs to match webpack 2 migration
1 parent 9434c9a commit 8a9125d

File tree

3 files changed

+67
-42
lines changed

3 files changed

+67
-42
lines changed

README.md

Lines changed: 5 additions & 0 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

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;

0 commit comments

Comments
 (0)