forked from uikit/uikit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
104 lines (92 loc) · 2.59 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
100
101
102
103
104
var fs = require('fs');
var glob = require('glob');
var path = require('path');
var webpack = require('webpack');
var util = require('./build/util');
var version = require('./package.json').version;
var loaders = {
loaders: [
{loader: 'buble-loader', test: /(src|tests)(\/|\\).*\.js$/},
{loader: 'json-loader', test: /\.json$/},
{loader: 'html-loader', test: /\.svg$/, options: {minimize: false}}
]
};
var 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,
externals: {jquery: 'jQuery'},
resolve: {
alias: {
"components$": __dirname + "/dist/icons/components.json",
}
},
plugins: [
new webpack.DefinePlugin({
BUNDLED: true,
VERSION: `'${version}'`
})
]
},
{
entry: './tests/js/uikit',
output: {
filename: 'dist/js/uikit.min.js',
library: 'UIkit',
libraryTarget: 'umd'
},
module: loaders,
externals: {jquery: 'jQuery'},
resolve: {
alias: {
"components$": __dirname + "/dist/icons/components.json",
}
},
plugins: [
new webpack.optimize.UglifyJsPlugin,
new webpack.DefinePlugin({
BUNDLED: true,
VERSION: `'${version}'`
})
]
},
{
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: {jquery: 'jQuery', uikit: 'UIkit'}
}
];