forked from melowntech/vts-browser-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
executable file
·77 lines (68 loc) · 1.97 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
var path = require('path');
var webpack = require('webpack');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var CommonChunks = require('copy-webpack-plugin');
var UglifyJsPlugin = webpack.optimize.UglifyJsPlugin;
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var LicenseWebpackPlugin = require('license-webpack-plugin');
var fs = require("fs");
var PROD = (process.env.NODE_ENV === 'production')
var TARGET_DIR = PROD ? __dirname + "/dist/" : __dirname + "/build/";
var plugins = [
new webpack.BannerPlugin(fs.readFileSync('./LICENSE', 'utf8')),
new LicenseWebpackPlugin({pattern: /^(MIT|ISC|BSD.*)$/})
];
if (PROD) {
plugins.push(new UglifyJsPlugin({
//comments: true,
compress: true,
mangle: true,
extractComments: {
"banner": function(filename) {
return "Copyright (c) 2017 Melown Technologies SE\n" +
" * For terms of use, see accompanying " + filename +" file.\n" +
" * For 3rd party libraries licenses, see 3rdpartylicenses.txt.\n"
}
},
}));
}
plugins.push(
new ExtractTextPlugin({
filename: 'vts-browser' + (PROD ? '.min' : '') + '.css'
})
);
var config = {
entry: {
'vts-core': __dirname + '/src/core/index.js',
'vts-browser': __dirname + '/src/browser/index.js'
},
devtool: PROD ? undefined : 'source-map',
output: {
path: TARGET_DIR,
filename: '[name]' + (PROD ? '.min' : '') + '.js',
libraryTarget: "var",
library: "vts"
},
module: {
loaders: [
{
include: [path.resolve(__dirname, "src/")]
},
{
test: /\.css$/, loader: ExtractTextPlugin.extract({fallback: "style-loader", use: "css-loader"})
},
]
},
resolve: {
modules : ['./node_modules/', './src/'],
alias: {
core: path.resolve(__dirname, 'src/core/'),
browser: path.resolve(__dirname, 'src/browser/')
}
},
devServer: {
inline: true
},
plugins: plugins
};
module.exports = config;