Skip to content

Commit

Permalink
fix(webpack): prevent other chunks from being injected to index.html (#…
Browse files Browse the repository at this point in the history
…108)

* fix(webpack): prevent other chunks from being injected to index.html

* fix(welcome): script error on no identity
  • Loading branch information
Sun Yi-Ran authored and Jack-Works committed Aug 15, 2019
1 parent c47a952 commit c418aea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions config-overrides.js
Expand Up @@ -32,6 +32,13 @@ module.exports = function override(/** @type{import("webpack").Configuration} */
config.module.exprContextCritical = false
config.module.unknownContextCritical = false

// Prevent all other chunks from being injected to index.html
config.plugins.forEach(p => {
if (p.constructor.name !== 'HtmlWebpackPlugin') return
const {devtools, app, ...exclude} = config.entry
Object.keys(exclude).forEach(e => p.options.excludeChunks.push(e))
})

config.plugins.push(
new (require('write-file-webpack-plugin'))({
test: /(webp|jpg|png|shim|polyfill|js\/.*|index\.html|manifest\.json|_locales)/,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Welcomes/1a1a.tsx
Expand Up @@ -28,7 +28,7 @@ const useStyles = makeStyles(theme => ({
}))
export default function Welcome({ next, identities, didntFindAccount }: Props) {
const classes = useStyles()
const [selected, setSelect] = useState<Person[]>([identities[0]])
const [selected, setSelect] = useState<Person[]>(identities[0] ? identities : [])
return (
<WelcomeContainer className={classes.paper}>
<Typography variant="h5">{geti18nString('welcome_1a1_title')}</Typography>
Expand Down

0 comments on commit c418aea

Please sign in to comment.