-
Notifications
You must be signed in to change notification settings - Fork 24
/
webpack.config.js
124 lines (115 loc) · 3.01 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
117
118
119
120
121
122
123
124
'use strict';
let path = require('path'),
webpack = require('webpack'),
pkg = require('./package.json'),
ExtractTextPlugin = require("extract-text-webpack-plugin"),
HtmlWebpackPlugin = require('html-webpack-plugin');
let paths = {
www: path.join(__dirname, 'www'),
src: path.join(__dirname, 'app')
}
let devtool = '#cheap-eval-source-map';
let appEntries = [];
let baseAppEntries = [
path.join(paths.src, 'app')
];
let devAppEntries = [
'webpack-dev-server/client',
'webpack/hot/only-dev-server'
];
let plugins = [];
let basePlugins = [
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.DefinePlugin({
__DEV__: process.env.NODE_ENV !== 'production',
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
}),
new HtmlWebpackPlugin({
template: path.join(paths.src, 'index.html'),
inject: 'body'
}),
new ExtractTextPlugin("styles.[hash].css")
];
let devPlugins = [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
];
let prodPlugins = [
new webpack.optimize.UglifyJsPlugin({
sourceMap: false,
compress: {
warnings: false
}
})
];
if (process.env.NODE_ENV === 'production') {
plugins = basePlugins.concat(prodPlugins);
appEntries = baseAppEntries.concat([]);
devtool = '#source-map';
} else { // dev or rest
plugins = basePlugins.concat(devPlugins);
appEntries = baseAppEntries.concat(devAppEntries);
}
module.exports = {
entry: {
app: appEntries,
polyfills: [
'core-js',
'reflect-metadata',
'zone.js'
],
vendors: [
'@angular/core',
'rxjs'
],
style: path.join(paths.src, 'scss', 'index.scss')
},
output: {
path: paths.www,
filename: '[name].[hash].js'
},
devtool: devtool,
resolve: {
extensions: ['', '.ts', '.js', '.html', '.scss', '.png'],
moduleDirectories: [
'node_modules',
'node_modules/ionic-angular',
'node_modules/ionicons/dist/scss/'
]
},
plugins: plugins,
module: {
preLoaders: [
// loaders.tslint,
],
loaders: [
{
test: /\.ts$/,
exclude: /(node_modules)/,
loaders: ['awesome-typescript-loader', 'angular2-template-loader'],
include: paths.src
}, {
test: /\.json$/,
loader: "json"
}, {
test: /\.(png|jpg|svg)$/,
loader: 'file?name=img/[ext]/[name].[ext]'
}, {
test: /\.scss$/,
loader: ExtractTextPlugin.extract(["css", "autoprefixer", "sass"])
}, {
test: /\.html$/,
loader: 'html'
}, {
test: [/ionicons\.svg/, /ionicons\.eot/, /ionicons\.ttf/, /ionicons\.woff/, /roboto-bold\.woff/, /roboto-medium\.woff/, /roboto-light\.woff/, /roboto-regular\.woff/, /roboto-bold\.ttf/, /roboto-medium\.ttf/, /roboto-light\.ttf/, /roboto-regular\.ttf/, /noto-sans-bold\.ttf/, /noto-sans-regular\.ttf/],
loader: 'file?name=fonts/[name].[ext]'
}
]
},
sassLoader: {
includePaths: [
"node_modules/ionic-angular",
"node_modules/ionicons/dist/scss"
]
}
};