-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
82 lines (80 loc) · 2.65 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
const settings = require('./application-settings.js');
var webpack = require('webpack'),
path = require('path'),
production = process.argv.indexOf('--production') !== -1,
NgAnnotatePlugin = require('ng-annotate-webpack-plugin'),
BrowserSyncPlugin = require('browser-sync-webpack-plugin'),
ExtractTextPlugin = require('extract-text-webpack-plugin'),
HtmlWebpackPlugin = require('html-webpack-plugin'),
spa = require('browser-sync-spa'),
appEntry = {},
plugins = [
new HtmlWebpackPlugin({
title: 'Cinema browser',
template: 'src/template-index.ejs', // Load a custom template
inject: 'body'
}),
new BrowserSyncPlugin({
host: 'localhost',
port: 4000,
server: {baseDir: [__dirname]}
}, {
use: spa({
selector: '[ng-app]'
})
}),
new webpack.optimize.CommonsChunkPlugin(
settings.appName,
settings.distFolder + '/' + settings.javascriptFolder + '/' + settings.appName + settings.isMinified(false)
),
new ExtractTextPlugin(settings.stylesheetPath),
new NgAnnotatePlugin({add: true})
];
if(production){
plugins.push(new webpack.optimize.DedupePlugin());
plugins.push(new webpack.optimize.OccurenceOrderPlugin());
plugins.push(new webpack.optimize.UglifyJsPlugin({warnings: false, minimize: true, drop_console: true}));
}
appEntry[settings.appName] = [
settings.sassEntryPoint,
settings.tsEntryPoint,
'.' + settings.sourceFolder + settings.stylesFolder + '/' + 'timeline.scss'
];
module.exports = {
context: __dirname,
entry: appEntry,
output: {
path: settings.outputFolder,
publicPath: '.',
filename: settings.distFolder + '/' + settings.javascriptFolder + "/[name]" + settings.isMinified(production)
},
resolve: {
extensions: ['', '.ts', '.js']
},
stats: {
colors: true,
reasons: true
},
devtool: !production && 'source-map',
module: {
preLoaders: [
{test: /\.ts$/, loader: 'tslint', exclude: /(node_modules|libs)/}
],
loaders: [
{test: /\.ts$/, loaders: ['ts-loader'], exclude: /(node_modules|libs)/},
{test: /\.html$/, loader: 'raw', exclude: /(node_modules|libs|dist|tsd|bower)/},
// stylesheets
{test: /\.scss/, exclude: /(node_modules|lib)/, loader: ExtractTextPlugin.extract('style-loader',
'css-loader!sass-loader')},
{test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader', 'css-loader')},
{test: /\.(png|jpg|gif|svg|woff|ttf|eot)/, loader: 'url-loader?limit=20480'}
// inline images/fonts less than 20Kb otherwise file-loader is used
]
},
plugins: plugins,
externals: {
'angular': 'angular',
'lodash': '_',
'moment': 'moment'
}
};