forked from mattlewis92/angular-bootstrap-calendar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.build.js
87 lines (83 loc) · 2.08 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
var webpack = require('webpack');
var ejs = require('ejs');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var EXCLUDE_TEMPLATES = process.argv.indexOf('--exclude-templates') > -1;
var MIN = process.argv.indexOf('-p') > -1;
var jsFilename = cssFilename = 'angular-bootstrap-calendar';
if (!EXCLUDE_TEMPLATES) {
jsFilename += '-tpls';
}
if (MIN) {
jsFilename += '.min';
cssFilename += '.min';
}
jsFilename += '.js';
cssFilename += '.css';
function getBanner() {
var pkg = require('./bower.json');
var banner = ['/**',
' * <%= pkg.name %> - <%= pkg.description %>',
' * @version v<%= pkg.version %>',
' * @link <%= pkg.homepage %>',
' * @license <%= pkg.license %>',
' */',
''].join('\n');
return ejs.render(banner, {pkg: pkg});
}
module.exports = {
entry: __dirname + '/src/entry.js',
output: {
path: __dirname + '/dist/js',
filename: jsFilename,
libraryTarget: 'umd'
},
externals: {
angular: 'angular',
moment: 'moment',
'interact.js': {
root: 'interact',
commonjs: 'interact.js',
commonjs2: 'interact.js',
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$/));
}