forked from uikit/uikit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
99 lines (87 loc) · 2.51 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/* eslint-env node */
const fs = require('fs');
const glob = require('glob');
const path = require('path');
const webpack = require('webpack');
const util = require('./build/util');
const {version} = require('./package.json');
const uglify = require('uglifyjs-webpack-plugin');
const circular = require('circular-dependency-plugin');
const loaders = {
loaders: [
{loader: 'buble-loader', test: /(src|tests)[/\\].*\.js$/},
{loader: 'json-loader', test: /\.json$/},
{loader: 'html-loader', test: /\.svg$/, options: {minimize: false}}
]
};
const components = {};
glob.sync('./src/js/components/*.js').forEach(file => components[path.basename(file, '.js')] = file.substring(0, file.length - 3));
module.exports = [
{
entry: './tests/js/uikit',
output: {
filename: 'dist/js/uikit.js',
library: 'UIkit',
libraryTarget: 'umd'
},
module: loaders,
plugins: [
// new circular,
new webpack.DefinePlugin({
BUNDLED: true,
VERSION: `'${version}'`
}),
new webpack.optimize.ModuleConcatenationPlugin()
]
},
{
entry: './tests/js/uikit',
output: {
filename: 'dist/js/uikit.min.js',
library: 'UIkit',
libraryTarget: 'umd'
},
module: loaders,
plugins: [
// new circular,
new webpack.DefinePlugin({
BUNDLED: true,
VERSION: `'${version}'`
}),
new webpack.optimize.ModuleConcatenationPlugin(),
new uglify
]
},
{
entry: './src/js/icons',
output: {
filename: 'dist/js/uikit-icons.js',
library: 'UIkitIcons',
libraryTarget: 'umd'
},
module: loaders,
plugins: [
{
apply(compiler) {
compiler.plugin('after-plugins', () => fs.writeFileSync('dist/icons.json', util.icons('src/images/icons/*.svg')));
compiler.plugin('done', () => fs.unlink('dist/icons.json', () => {}));
}
}
],
resolve: {
alias: {
'icons$': __dirname + '/dist/icons.json',
}
}
},
{
entry: {
index: './tests/js/index'
},
output: {
filename: 'tests/js/test.js'
},
module: loaders,
externals: {uikit: 'UIkit'}
}
];