-
Notifications
You must be signed in to change notification settings - Fork 27
/
webpack.config.js
executable file
·82 lines (76 loc) · 1.98 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
const path = require('path');
const uglifyJS = require('uglify-js');
const CleanCSS = require('clean-css');
const MergeIntoSingle = require('./index.node6-compatible.js');
// const MergeIntoSingle = require('./index.js');
// Webpack Config
const webpackConfig = {
devServer: {
contentBase: path.join(__dirname, 'example'),
compress: true,
port: 3000,
open: true,
},
mode: 'none',
entry: ['./example/main.js'],
devtool: 'cheap-module-source-map',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, './dist'),
},
resolve: {
extensions: ['.js', '.css'],
},
plugins: [
new MergeIntoSingle({
files: [{
src: [
'node_modules/jquery/**/*.min.js',
'node_modules/classnames/index.js',
'node_modules/humps/humps.js',
],
dest: (code) => {
const min = uglifyJS.minify(code, {
sourceMap: {
filename: 'vendor.js',
url: 'vendor.js.map',
},
});
return {
'vendor.js': min.code,
'vendor.js.map': min.map,
};
},
}, {
src: ['example/test.css'],
dest: (code) => ({
'style.css': new CleanCSS({}).minify(code).styles,
}),
}],
// also possible:
// files:{
// 'vendor.js':[
// 'node_modules/jquery/**/*.min.js',
// 'node_modules/classnames/index.js',
// 'node_modules/humps/humps.js',
// ],
// 'style.css':[
// 'example/test.css',
// ]
// },
// transform:{
// 'vendor.js': code => uglifyJS.minify(code).code,
// 'style.css': code => new CleanCSS({}).minify(code).styles,
// },
hash: false,
}, (filesMap) => {
console.log('generated files: ', filesMap); // eslint-disable-line no-console
}),
],
module: {
rules: [
{ test: /\.html$/, loader: 'raw-loader' },
],
},
};
module.exports = webpackConfig;