-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
79 lines (68 loc) · 2.14 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/// <reference path="typings/node/node.d.ts"/>
var path = require('path');
var webpackShared = require('./webpack.shared');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var nodeModulesPath = path.join(__dirname, 'node_modules');
var config = {
// entry points - each will produce one bundled js file and one css file if there is any css in dependency tree
entry: {
vendors: [
'flux',
'react',
'react-dom',
'immutable'
],
app: [
path.join(__dirname, 'app', 'Index.tsx')
]
},
// This is path to loaders
resolveLoader: {
root: nodeModulesPath
},
resolve: {
extensions: ['', '.tsx', '.ts', '.js', '.less', '.css', '.scss'],
modulesDirectories: ['node_modules', 'resources'],
alias: {
'react': path.join(nodeModulesPath, 'react', 'react.js'),
'react-dom': path.join(nodeModulesPath, 'react-dom', 'dist', 'react-dom.js'),
'flux': path.join(nodeModulesPath, 'flux', 'index.js')
}
},
output: {
path: path.join(__dirname, 'build'),
filename: '[name].js'
},
module: {
preLoaders: [
{ test: /\.ts(x?)$/, loader: 'tslint', include: path.resolve(__dirname, 'app') }
],
noParse: [],
loaders: [
{ test: /\.ts(x?)$/, loader: 'awesome-typescript-loader?instance=jsx', include: path.resolve(__dirname, 'app') }
]
},
plugins: [
// new webpack.optimize.CommonsChunkPlugin('vendors', 'vendors_[chunkhash].js'),
new webpack.optimize.CommonsChunkPlugin('vendors', 'vendors.js'),
new webpack.optimize.UglifyJsPlugin({minimize: true}),
new ExtractTextPlugin('[name].css', { allChunks: true })
],
tslint: {
// Rules are in tslint.json
emitErrors: true, // false = WARNING for webpack, true = ERROR for webpack
formattersDirectory: path.join(nodeModulesPath, 'tslint-loader', 'formatters')
}
};
if (webpackShared.isProduction) {
config.plugins.push(new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}));
config.plugins.push(new webpack.DefinePlugin({
'process.env': {NODE_ENV: 'production'}
}));
}
module.exports = config;