Skip to content

Commit 4ab8bfd

Browse files
committed
rename output file name
1 parent e96af5a commit 4ab8bfd

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ node server.js
7979
```js
8080
const entries = {}
8181
const chunks = []
82-
glob.sync('./src/pages/**/*.js').forEach(path => {
82+
glob.sync('./src/pages/**/app.js').forEach(path => {
8383
// Get all the entry js files and forEach them
8484

85-
const chunk = path.split('./src/pages/')[1].split('.js')[0]
86-
// E.g, chunk = 'user/index/app' path = './src/pages/user/index/app.js'
85+
const chunk = path.split('./src/pages/')[1].split('/app.js')[0]
86+
// E.g, chunk = 'user/index' path = './src/pages/user/index/app.js'
8787

8888
entries[chunk] = path
8989
// Now we got the entries
@@ -116,15 +116,15 @@ node server.js
116116
// ...
117117
}
118118
// ...
119-
glob.sync('./src/pages/**/*.html').forEach(path => {
119+
glob.sync('./src/pages/**/app.html').forEach(path => {
120120
// Get all the html template files and forEach them
121121
// E.g, path = './src/pages/user/index/app.html'
122122
123123
const filename = path.split('./src/pages/')[1].split('/app.html')[0] + '.html'
124124
// E.g, the html filename will be 'user/index.html' in the 'dist' folder
125125
126-
const chunk = path.split('./src/pages/')[1].split('.html')[0]
127-
// E,g. the chunk will be 'user/login/app'
126+
const chunk = path.split('./src/pages/')[1].split('/app.html')[0]
127+
// E,g. the chunk will be 'user/login'
128128
129129
const htmlConf = {
130130
filename: filename,
@@ -141,4 +141,5 @@ node server.js
141141
## Inspired by [element-starter](https://github.com/ElementUI/element-starter)
142142

143143
## License
144+
144145
MIT

webpack.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ const CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin')
88

99
const entries = {}
1010
const chunks = []
11-
glob.sync('./src/pages/**/*.js').forEach(path => {
12-
const chunk = path.split('./src/pages/')[1].split('.js')[0]
11+
glob.sync('./src/pages/**/app.js').forEach(path => {
12+
const chunk = path.split('./src/pages/')[1].split('/app.js')[0]
1313
entries[chunk] = path
1414
chunks.push(chunk)
1515
})
@@ -107,7 +107,7 @@ const config = {
107107

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

0 commit comments

Comments
 (0)