-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.components.js
52 lines (51 loc) · 1.2 KB
/
webpack.components.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
/*
* @Description:
* @Version: 2.0
* @Author: 黄博文
* @Date: 2022-04-14 19:19:29
* @LastEditors: 黄博文
* @LastEditTime: 2022-04-26 12:03:01
*/
const path = require('path')
const glob = require('glob')
const { VueLoaderPlugin } = require('vue-loader')
const list = {}
// {
// card: './components/lib/card/index.js',
// demo: './components/lib/demo/index.js',
// link: './components/lib/link/index.js',
// button: './components/lib/button/index.js',
// }
async function getComponents(dirPath, list) {
const files = glob.sync(`${dirPath}/**/*.js`)
files.forEach((file) => {
const component = file.split(/[/.]/)[2]
list[component] = `./${file}`
})
}
getComponents('components/lib', list)
module.exports = {
// entry: list, //取消打包多入口
entry: './components/lib/index.js',
mode: 'production',
output: {
// filename: '[name].umd.js', //取消打包多入口
filename: 'index.umd.js',
path: path.resolve(__dirname, 'dist'),
library: 'Aui',
libraryTarget: 'umd'
},
plugins: [new VueLoaderPlugin()],
module: {
rules: [
{
test: /\.vue$/,
use: [
{
loader: 'vue-loader'
}
]
}
]
}
}