Skip to content

Commit

Permalink
fix(umi-build-dev): 404 page generate failed when exportStatic is set (
Browse files Browse the repository at this point in the history
  • Loading branch information
sorrycc committed Mar 29, 2018
1 parent 30684ec commit ec637c2
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 6 deletions.
9 changes: 5 additions & 4 deletions examples/func-test/.umirc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export default {
pages: {
'/': { context: { title: '首页' } },
'list.html': { context: { title: '列表页' } },
'/list': { document: 'pages/list.ejs', context: { title: '列表页' } },
'/404': { document: 'pages/404.ejs' },
},
plugins: [
'umi-plugin-dll',
Expand All @@ -12,8 +13,8 @@ export default {
hd: 1,
loading: './PageLoadingComponent',
// disableServiceWorker: true,
// exportStatic: {
// htmlSuffix: true,
// },
exportStatic: {
// htmlSuffix: true,
},
outputPath: './www',
};
16 changes: 16 additions & 0 deletions examples/func-test/pages/404.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title><%= context.title %></title>
</head>
<body>

<h1>404 Page</h1>
<div id="root"></div>

</body>
</html>
16 changes: 16 additions & 0 deletions examples/func-test/pages/list.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title><%= context.title %></title>
</head>
<body>

<h1>List Page</h1>
<div id="root"></div>

</body>
</html>
4 changes: 2 additions & 2 deletions packages/umi-build-dev/src/plugins/404/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export function patchRoutes(routes) {
}

export default function(api) {
const { paths } = api.service;
const { paths, config } = api.service;

if (process.env.NODE_ENV === 'production') {
if (process.env.NODE_ENV === 'production' && !config.exportStatic) {
api.register('modifyRoutes', ({ memo }) => {
return patchRoutes(memo);
});
Expand Down

0 comments on commit ec637c2

Please sign in to comment.