Skip to content

Commit

Permalink
chore: add prerender plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Winme committed Mar 9, 2020
1 parent 6156e8f commit 81530df
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
20 changes: 17 additions & 3 deletions config-overrides.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
const { override, addLessLoader, addWebpackAlias, fixBabelImports, addWebpackPlugin } = require('customize-cra')
const path = require('path')
// const darkThemeVars = require('antd/dist/dark-theme')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const AntDesignThemePlugin = require('antd-theme-webpack-plugin');
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
const AntDesignThemePlugin = require('antd-theme-webpack-plugin')
const PrerenderSPAPlugin = require('prerender-spa-plugin')

const options = {
antDir: path.join(__dirname, './node_modules/antd'),
Expand All @@ -16,11 +17,23 @@ const options = {

const resolve = dir => path.join(__dirname, '.', dir)

const rewiredSourceMap = () => config => {
const rewiredSourceMap = () => (config) => {
config.devtool = config.mode === 'development' ? 'cheap-module-source-map' : false
return config
}

const prerenderPlugin = () => (config) => {
if (config.mode === 'production') {
config.plugins = config.plugins.concat([
new PrerenderSPAPlugin({
routes: ['/dashboard'],
staticDir: path.join(__dirname, 'build'),
}),
]);
}
return config
}

module.exports = override(
fixBabelImports('import', {
libraryName: 'antd',
Expand All @@ -42,5 +55,6 @@ module.exports = override(
// new BundleAnalyzerPlugin(),
new AntDesignThemePlugin(options)
),
prerenderPlugin(),
rewiredSourceMap()
)
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"http-proxy-middleware": "^0.20.0",
"less": "^2.7.0",
"less-loader": "^5.0.0",
"prerender-spa-plugin": "^3.4.0",
"prettier": "^1.19.1",
"react-app-rewired": "^2.1.5",
"redux-devtools-extension": "^2.13.8",
Expand Down

0 comments on commit 81530df

Please sign in to comment.