-
Notifications
You must be signed in to change notification settings - Fork 90
/
Copy pathwebpack.base.config.js
106 lines (86 loc) · 2.33 KB
/
webpack.base.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
/**
* Created by admin on 2017/8/31.
*/
/**
* Created by admin on 2017/8/30.
*/
/**
* Created by admin on 2017/8/17.
*/
var path = require('path');
var fs = require('fs')
var webpack = require('webpack');
var CopyWebpackPlugin = require('copy-webpack-plugin')
var glob = require('glob')
// function getEntry() {
// var entry = [];
// var srcDirName = './src/utils/*.js'; //入口文件夹路径
// glob.sync(srcDirName).forEach(function (name) { //n 获取文件名字
// var n = name.slice(0, name.length - 3);
// n = n.slice(n.lastIndexOf('/')).split("/")[1];
// entry.push(name.replace('src/', ''));
// });
//
// return entry;
// }
function getDir(str) {
var dir = fs.readdirSync(str);
return dir.filter((item) => {
var v = path.resolve(__dirname, item);
if (fs.existsSync(v) && fs.statSync(v).isFile()) {
return /^app.*/i.test(item)
} else {
return (!/(node_modules|dist|.idea)/i.test(item))
}
return (!/(node_modules|dist)/i.test(item) && !/^app.*/i.test(item)) || /^app.*/i.test(item)
}).map((obj) => {
return {
from: path.resolve(__dirname, obj),
to: path.resolve(__dirname, 'dist', obj)
}
})
}
module.exports = {
context: path.join(__dirname, 'src/es6'),
entry: {
myapp:'./myapp.js'
},
output: {
path: path.join(__dirname, 'dist/src/lib'),
filename: '[name].js',
libraryTarget: 'umd'
},
module: {
rules: [
{
test: /\.js$/,
query: {
presets: ['es2015','stage-0']
},
loader: 'babel-loader',
exclude: /node_modules/
},
]
},
plugins: [
new CopyWebpackPlugin([
{
from: path.join(__dirname, '/src'),
to: path.join(__dirname, '/dist/src')
}
],{
ignore: [
'es6/*.js',
'*.less',
'*.css'
// 'es6/*.js',
/*'pages/!**!/!*.less',
'pages/!**!/!**!/!*.less',*/
],
copyUnmodified: true
}),
],
resolve: {
extensions: ['.js']
},
}