This repository has been archived by the owner on Jul 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
/
webpack.config.js
75 lines (60 loc) · 1.53 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
/*
* @Author: dmyang
* @Date: 2015-11-10 10:42:22
* @Last Modified by: dmyang
* @Last Modified time: 2016-06-01 10:58:48
*/
'use strict';
const path = require('path')
const fs = require('fs')
const webpack = require('webpack')
const assets = './dist/'
let genEntries = () => {
let jsDir = path.resolve(__dirname, 'api')
let names = fs.readdirSync(jsDir)
let map = {}
names.forEach((name) => {
let m = name.match(/(.+)\.js(?:x)?$/)
let entry = m ? m[1] : ''
let entryPath = entry ? path.resolve(jsDir, name) : ''
if(entry) map['hybrid-' + entry] = [entryPath]
})
return map
}
let entry = genEntries()
entry['hybrid'] = entry['hybrid-base']
delete entry['hybrid-base']
let config = {
entry: entry,
output: {
filename: 'dist/[name].js',
library: 'HybridJS',
libraryTarget: 'umd', // 兼容各种模块化写法
},
resolve: {
root: __dirname,
extensions: ['', '.js', '.jsx']
},
module: {
loaders: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loader: 'babel?presets[]=es2015'
},
{
test: /\.less$/,
loader: 'style!css!less'
},
{
test: /\.css$/,
loader: 'style!css'
},
{
test: /\.(png|jpg)$/,
loader: 'url?limit=8192&prefix=img/'
}
]
}
}
module.exports = config