forked from mattlewis92/angular-bootstrap-calendar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.build.js
102 lines (93 loc) · 2.3 KB
/
webpack.config.build.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
'use strict';
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = env => {
env = env || {};
const MIN = process.argv.indexOf('-p') > -1;
let cssFilename, jsFilename;
jsFilename = cssFilename = 'angular-bootstrap-calendar';
if (!env.excludeTemplates) {
jsFilename += '-tpls';
}
if (MIN) {
jsFilename += '.min';
cssFilename += '.min';
}
jsFilename += '.js';
cssFilename += '.css';
function getBanner() {
const pkg = require('./package.json');
return `
/**
* ${pkg.name} - ${pkg.description}
* @version v${pkg.version}
* @link ${pkg.homepage}
* @license ${pkg.license}
*/
`.trim();
}
const config = {
entry: __dirname + '/src/entry.js',
output: {
path: __dirname + '/dist/js',
filename: jsFilename,
libraryTarget: 'umd',
library: 'angularBootstrapCalendarModuleName'
},
externals: {
angular: 'angular',
moment: 'moment',
'interactjs': {
root: 'interact',
commonjs: 'interactjs',
commonjs2: 'interactjs',
amd: 'interact'
}
},
devtool: MIN ? 'source-map' : false,
module: {
rules: [{
test: /.*\.js$/,
loader: 'eslint-loader',
exclude: /node_modules/,
enforce: 'pre'
}, {
test: /\.html$/,
loader: 'htmlhint-loader',
exclude: /node_modules/,
enforce: 'pre'
}, {
test: /.*\.js$/,
loader: 'ng-annotate-loader',
exclude: /node_modules/
}, {
test: /\.html$/,
loader: 'html-loader',
exclude: /node_modules/
}, {
test: /\.less/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader?sourceMap!less-loader?sourceMap'
}),
exclude: /node_modules/
}]
},
plugins: [
new webpack.NoEmitOnErrorsPlugin(),
new webpack.BannerPlugin({
banner: getBanner(),
raw: true,
entryOnly: true
}),
new ExtractTextPlugin('../css/' + cssFilename),
new webpack.DefinePlugin({
EXCLUDE_TEMPLATES: env.excludeTemplates
})
]
};
if (env.excludeTemplates) {
config.plugins.push(new webpack.IgnorePlugin(/templates\/(.+)\.html$/));
}
return config;
};