Skip to content

Commit

Permalink
next.js 5.0+ 对dynamic的bug到现在还没解决 dev环境报错, pro正常 vercel/next.js#3775
Browse files Browse the repository at this point in the history
  • Loading branch information
niu_hl committed Jun 26, 2018
1 parent d9bc265 commit 9b7783d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
Binary file modified blog.sqlite
Binary file not shown.
3 changes: 0 additions & 3 deletions components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ const Header = () => (
<Link href="/">
<a style={linkStyle}>Home</a>
</Link>
<Link href="/about">
<a style={linkStyle}>About</a>
</Link>
</div>
)

Expand Down
18 changes: 13 additions & 5 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,28 @@ const withLess = require('@zeit/next-less')
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
// import withLess from '@zeit/next-less'
// import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'
const { ANALYZE } = process.env

module.exports = withLess({
// 直接导出静态文件
exportPathMap: (defaultPathMap) => ({
'/': { page: '/' },
'/p/:id': { page: '/post' },
}),
lessLoaderOptions: {
javascriptEnabled: true,
},
distDir: 'build',
// generateEtags: false,
useFileSystemPublicRoutes: false,
webpack: (config, { isServer }) => {
config.plugins.push(new BundleAnalyzerPlugin({
analyzerMode: 'server',
analyzerPort: isServer ? 8888 : 8889,
openAnalyzer: true
}))
if (ANALYZE) {
config.plugins.push(new BundleAnalyzerPlugin({
analyzerMode: 'server',
analyzerPort: isServer ? 8888 : 8889,
openAnalyzer: true
}))
}
return config;
}
})
8 changes: 0 additions & 8 deletions pages/about.js

This file was deleted.

8 changes: 5 additions & 3 deletions pages/post.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
// import axios from 'axios'
import dynamic from 'next/dynamic'
import { withRouter } from 'next/router'
import Layout from '../components/MyLayout.js'
// import SqlTag from '../components/SqlTag.js'
// import MongoTag from '../components/MongoTag.js'
// import Breadcrumb from '../components/Breadcrumb.js'
import { Button } from 'antd'
import dynamic from 'next/dynamic'
import { Button, Spin } from 'antd'

const SqlTag = dynamic(import('../components/SqlTag'))
const MongoTag = dynamic(import('../components/MongoTag'))
const Breadcrumb = dynamic(import('../components/Breadcrumb'))
const Breadcrumb = dynamic(import('../components/Breadcrumb'), {
loading: () => <Spin />,
})

class Post extends React.Component {
static async getInitialProps({query}) {
Expand Down

0 comments on commit 9b7783d

Please sign in to comment.