-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
57 lines (50 loc) · 1.17 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
'use strict'
const fs = require('fs')
const path = require('path')
const webpack = require('webpack')
const getEntries = () => {
const dirEntries = (itemPath, files) => {
if (fs.statSync(itemPath).isDirectory()) {
fs.readdirSync(itemPath).forEach(item => {
dirEntries(path.resolve(itemPath, item), files)
})
} else {
const matchs = itemPath.match(/(.+)\.ts$/)
if (!!matchs) files[path.basename(itemPath, '.ts')] = itemPath
}
}
const srcPath = path.resolve(process.cwd(), 'src')
const dirs = fs.readdirSync(srcPath)
const files = {}
dirs.forEach(item => {
dirEntries(path.resolve(srcPath, item), files)
})
return files
}
module.exports = {
entry: getEntries(),
output: {
path: path.join(__dirname, 'pack/js'),
filename: '[name].js'
},
module: {
loaders: [
{
exclude: path.resolve(__dirname, 'node_modules'),
test: /\.ts$/,
loader: 'ts-loader'
}
]
},
resolve: {
extensions: ['.ts', '.js'],
modules: ['node_modules']
},
plugins: [
new webpack.IgnorePlugin(/\.git$/),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery'
})
]
}