-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
89 lines (84 loc) · 2.25 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
83
84
85
86
87
88
89
const path = require('path');
function getPageIndex(filePath) {
return new Promise(async (res) => {
const result = [];
const files = await readDir(filePath);
for (const v of files) {
const fileDir = path.join(filePath, v);
const stats = await stat(fileDir);
if (stats.isDirectory()) {
const e = await getPageIndex(fileDir);
result.push(...e)
} else if (stats.isFile() && v === 'page-index.ts') {
result.push(fileDir)
}
}
res(result);
});
}
function readDir(path) {
return new Promise((res, rej) => {
fs.readdir(path, (err, files) => {
if (err) {
rej();
} else {
res(files)
}
});
})
}
function stat(path) {
return new Promise((res, rej) => {
fs.stat(path, (err, files) => {
if (err) {
rej();
} else {
res(files)
}
});
})
}
const appSrc = path.resolve(__dirname, 'src');
const appNodeModules = path.resolve(__dirname, 'node_modules');
module.exports = {
mode: 'development',
resolve: {
modules: ['node_modules', appNodeModules],
extensions: [
'.mjs',
'.web.ts',
'.ts',
'.web.tsx',
'.tsx',
'.web.js',
'.js',
'.json',
'.web.jsx',
'.jsx'
],
alias: {
'@src': appSrc
},
},
module: {
rules: [
{
oneOf: [
{
test: /\.ts$/,
enforce: 'pre',
use: [
require.resolve('babel-loader'),
{
loader: require.resolve('ts-loader'),
options: {
transpileOnly: true,
}
}
]
}
]
}
]
}
};