styled-components-website icon indicating copy to clipboard operation
styled-components-website copied to clipboard

FAQ needs an update

Open harsh8398 opened this issue 3 years ago • 4 comments
trafficstars

The current FAQ has a section providing webpack configuration: https://styled-components.com/docs/faqs#running-multiple-applications-on-one-page which would not work from webpack v4 (https://webpack.js.org/plugins/split-chunks-plugin/) and requires an update for doc readers. I haven't tasted the following config but it should be something along these lines for webpack >= 4.

{
...
optimization: {
      splitChunks: {
        cacheGroups: {
          "styled-components": {
            test: /[\\/]node_modules[\\/](styled-components)[\\/]/,
            chunks: 'all',
            priority: 1
          },
        },
      },
    },
...
}

harsh8398 avatar Feb 03 '22 06:02 harsh8398

I found that someone has already done the work here to come up with the config: https://github.com/styled-components/styled-components/issues/2974#issuecomment-994921094.

Also, a similar config for anyone using rollup is available here: https://www.rollupjs.org/guide/en/#outputmanualchunks

manualChunks(id) {
  if (id.includes('node_modules')) {
    return 'vendor';
  }
}

harsh8398 avatar Feb 03 '22 06:02 harsh8398

Feel free to submit a PR, thanks

quantizor avatar Aug 09 '22 15:08 quantizor

@probablyup, there was already one PR https://github.com/styled-components/styled-components-website/pull/378 addressing this, but it was closed for some reason. Do we need to raise it again? We can also add a section for rollup configuration.

harsh8398 avatar Aug 17 '22 14:08 harsh8398

@harsh8398 sure, please feel free to recreate it

quantizor avatar Aug 31 '22 02:08 quantizor