-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.vendor.js
63 lines (58 loc) · 1.94 KB
/
webpack.config.vendor.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
"use strict";
const VENDOR = [
'bootstrap/dist/css/bootstrap.css',
'font-awesome/css/font-awesome.css',
'es6-shim',
'classnames',
'react',
'react-dom',
'react-router-dom',
'servicestack-client'
];
const path = require('path'),
webpack = require('webpack'),
ExtractTextPlugin = require('extract-text-webpack-plugin'),
Clean = require('clean-webpack-plugin');
module.exports = (env) => {
const extractCSS = new ExtractTextPlugin('vendor.dll.css');
const isDev = !(env && env.prod);
return [{
entry: { vendor: VENDOR },
stats: { modules: false },
resolve: {
extensions: [ '.js' ]
},
module: {
rules: [
{ test: /\.(png|woff|woff2|eot|ttf|svg)(\?|$)/, use: 'url-loader?limit=100000' },
{ test: /\.css(\?|$)/, use: extractCSS.extract([ isDev ? 'css-loader' : 'css-loader?minimize' ]) }
]
},
devtool: "source-map",
output: {
path: root('wwwroot/dist'),
publicPath: 'dist/',
filename: '[name].dll.js',
library: '[name]_[hash]',
},
plugins: [
new Clean([root('wwwroot/dist')]),
extractCSS,
new webpack.DllPlugin({
path: path.join(__dirname, 'wwwroot', 'dist', '[name]-manifest.json'),
name: '[name]_[hash]'
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': isDev ? '"development"' : '"production"'
})
].concat(isDev ? [] : [
new webpack.optimize.UglifyJsPlugin({ sourceMap: true }),
new Clean([root('bin/Release/netcoreapp2.0/publish/wwwroot/dist')]),
])
}];
//helpers
function root(args) {
args = Array.prototype.slice.call(arguments, 0);
return (path || (path = require("path"))).join.apply(path, [__dirname].concat(args));
}
};