-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
executable file
·111 lines (100 loc) · 3.36 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
var webpack = require("webpack");
var DefinePlugin = require('webpack/lib/DefinePlugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var UglifyJsPlugin = require('webpack/lib/optimize/UglifyJsPlugin');
var ProvidePlugin = require('webpack/lib/ProvidePlugin');
//Set environment to development
var ENV = process.env.NODE_ENV = process.env.ENV = 'development';
//Get host from environment variable. If not found, set to localhost
var HOST = process.env.HOST || 'localhost';
//Get port from environment variable. If not found, set to 8080
var PORT = process.env.PORT || 8080;
//Setup metadata (to be used by index.html)
var metadata = {
title: 'Storykart',
baseUrl: '/',
host: HOST,
port: PORT,
ENV: ENV
};
module.exports = {
entry: {
"vendor": "./src/vendor",
"main": "./src/main"
},
output: {
path: __dirname,
filename: "./build/[name].bundle.js",
sourceMapFilename: './build/[name].map'
},
resolve: {
//ToDo
cache: false,
// Webpack will process these file extensions
extensions: ['','.ts','.js','.json','.css','.html'],
alias: {
'jquery-ui': 'jquery-ui/ui/widgets'
}
},
devtool: 'source-map',
module: {
loaders: [
{
test: /\.ts/,
loaders: ['ts-loader'],
exclude: /node_modules/
},
// Handles JSON files.
{ test: /\.json$/, loader: 'json-loader' },
// Support for CSS as raw text
{ test: /\.css$/, loader: 'raw-loader' },
// Support for .html as raw text
{ test: /\.html$/, loader: 'raw-loader'},
// Compiles SCSS to CSS
{ test: /\.scss$/, loaders: ['raw-loader', 'sass-loader'] },
// Handles imaage files. Uses data urls if file size is less than 10KB, else loads files using file loader
{ test: /\.(woff2?|ttf|eot|svg)$/, loader: 'url?limit=10000&name=[name].[ext]' }
]
},
plugins: [
new webpack.optimize.CommonsChunkPlugin(/* chunkName= */"vendor", /* = */"./build/vendor.bundle.js"),
// Makes a module available as variable in every module.
new webpack.ProvidePlugin({
jQuery: 'jquery',
$: 'jquery',
jquery: 'jquery'
}),
// Copy assets to build folder
new CopyWebpackPlugin([
{
from: 'src/assets',
to: 'build/assets'
}
]),
// Setup Global Javascript Variables
new webpack.DefinePlugin({
'process.env': {
'ENV': JSON.stringify(metadata.ENV),
'NODE_ENV': JSON.stringify(metadata.ENV)
}
}),
//Uglify JS files
new UglifyJsPlugin({
// to debug prod builds uncomment //debug lines and comment //prod lines
// beautify: true,//debug
// mangle: false,//debug
// dead_code: false,//debug
// unused: false,//debug
// deadCode: false,//debug
// compress : { screw_ie8 : true, keep_fnames: true, drop_debugger: false, dead_code: false, unused: false, }, // debug
// comments: true,//debug
beautify: false,//prod
// disable mangling because of a bug in angular2 beta.1, beta.2 and beta.3
// TODO(mastertinner): enable mangling as soon as angular2 beta.4 is out
// mangle: { screw_ie8 : true },//prod
mangle: false,
compress : { screw_ie8 : true, warnings: false},//prod
comments: false//prod
})
]
}