-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
116 lines (107 loc) · 2.33 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
* Helper: root(), and rootDir() are defined at the bottom
*/
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const path = require('path')
/*
* Webpack Plugins
*/
var webpack = require('webpack');
var CommonsChunkPlugin = webpack.optimize.CommonsChunkPlugin;
var ProvidePlugin = webpack.ProvidePlugin;
/*
* SASS Config
*/
const sassLoaders = [
'css',
'sass'
]
/*
* Config
*/
const config = {
devtool: 'source-map',
debug: true,
entry: {
'angular2': [
'rxjs',
'reflect-metadata',
'angular2/core',
'angular2/router',
'angular2/http'
],
'app': [
'./src/app',
'./src/scss'
],
'head': [
'./src/app/head'
]
},
output: {
path: root('build'),
publicPath: 'build/',
filename: '[name].js',
sourceMapFilename: '[name].js.map',
chunkFilename: '[id].chunk.js'
},
resolve: {
extensions: ['','.ts','.js','.json', '.scss', '.css', '.styl', '.html']
},
module: {
preLoaders: [
{
test: /\.json$/,
exclude: /node_modules/,
loader: 'json'},
],
loaders: [
{
test: /\.ts$/,
loader: 'ts',
exclude: [ /node_modules/ ]},
{
test: /\.js$/,
loaders: ['babel-loader'],
exclude: [ /node_modules/ ]},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract('style', sassLoaders),
//loaders: styleLoaders,
//loaders: ['style', 'css', 'sass'],
exclude: [ /node_modules/ ]},
{
test: /\.styl$/,
loaders: ['css', 'stylus'],
exclude: [ /node_modules/ ]
},
{
test: /\.json$/,
loader: 'json' }
],
resolve: {
modulesDirectories: ['node_modules']
}
},
plugins: [
new CommonsChunkPlugin({ name: 'angular2', filename: 'angular2.js', minChunks: Infinity }),
new CommonsChunkPlugin({ name: 'common', filename: 'common.js' }),
new ExtractTextPlugin('[name].css')
],
target: 'node-webkit'
};
/*
* Helper functions
*/
function root(args) {
args = Array.prototype.slice.call(arguments, 0);
return path.join.apply(path, [__dirname].concat(args));
}
function rootNode(args) {
args = Array.prototype.slice.call(arguments, 0);
return root.apply(path, ['node_modules'].concat(args));
}
/*
* Export module
*/
module.exports = config