Skip to content

Commit 90edcd1

Browse files
keyiranallen-zh
authored andcommitted
feat(build): support lazy-load route in h5 (#182)
1 parent 0a87533 commit 90edcd1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/mars-build/src/gulp-mars-h5.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,12 @@ async function compile(file, opt) {
308308
allPages.forEach(page => {
309309
const name = `_${md5(page).substr(0, 8)}`;
310310
// const name = page.replace(/\//g, '$');
311-
content += `import ${name} from './${page}.vue';\n`;
311+
if (options._config.h5 && options._config.h5.useLazyRoute) {
312+
content += `const ${name} = () => import('./${page}.vue');\n`;
313+
}
314+
else {
315+
content += `import ${name} from './${page}.vue';\n`;
316+
}
312317
routes.push({
313318
path: '/' + page,
314319
name

0 commit comments

Comments
 (0)