Skip to content

Commit 6aa69d7

Browse files
committed
Optimized config code
1 parent 4ab8bfd commit 6aa69d7

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,14 @@ node server.js
120120
// Get all the html template files and forEach them
121121
// E.g, path = './src/pages/user/index/app.html'
122122
123-
const filename = path.split('./src/pages/')[1].split('/app.html')[0] + '.html'
124-
// E.g, the html filename will be 'user/index.html' in the 'dist' folder
125-
126123
const chunk = path.split('./src/pages/')[1].split('/app.html')[0]
127124
// E,g. the chunk will be 'user/login'
128125
126+
const filename = chunk + '.html'
127+
// E.g, the html filename will be 'user/index.html' in the 'dist' folder
128+
129+
130+
129131
const htmlConf = {
130132
filename: filename,
131133
template: path,

webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ const config = {
106106
}
107107

108108
glob.sync('./src/pages/**/*.html').forEach(path => {
109-
const filename = path.split('./src/pages/')[1].split('/app.html')[0] + '.html'
110109
const chunk = path.split('./src/pages/')[1].split('/app.html')[0]
110+
const filename = chunk + '.html'
111111
const htmlConf = {
112112
filename: filename,
113113
template: path,

0 commit comments

Comments
 (0)