forked from mattlewis92/angular-bootstrap-calendar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.build.js
90 lines (85 loc) · 2.04 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
'use strict';
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const EXCLUDE_TEMPLATES = process.argv.indexOf('--exclude-templates') > -1;
const MIN = process.argv.indexOf('-p') > -1;
let cssFilename, jsFilename;
jsFilename = cssFilename = 'angular-bootstrap-calendar';
if (!EXCLUDE_TEMPLATES) {
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();
}
module.exports = {
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' : null,
module: {
preLoaders: [{
test: /.*\.js$/,
loaders: ['eslint'],
exclude: /node_modules/
}, {
test: /\.html$/,
loader: 'htmlhint',
exclude: /node_modules/
}],
loaders: [{
test: /.*\.js$/,
loaders: ['ng-annotate'],
exclude: /node_modules/
}, {
test: /\.html$/,
loader: 'html',
exclude: /node_modules/
}, {
test: /\.less$/,
loader: ExtractTextPlugin.extract('style-loader', 'css?sourceMap!less?sourceMap'),
exclude: /node_modules/
}]
},
plugins: [
new webpack.NoErrorsPlugin(),
new webpack.BannerPlugin(getBanner(), {
raw: true,
entryOnly: true
}),
new ExtractTextPlugin('../css/' + cssFilename),
new webpack.DefinePlugin({
EXCLUDE_TEMPLATES: EXCLUDE_TEMPLATES
})
]
};
if (EXCLUDE_TEMPLATES) {
module.exports.plugins.push(new webpack.IgnorePlugin(/templates\/(.+)\.html$/));
}