How to disable code splitting. I tried but unable to find suitable settings.
I tried this one.
gatsby-node.js
const webpack = require(`webpack`);
exports.onCreateWebpackConfig = ({ stage, actions }, options) => {
console.log('==== Disabling Chunk ====');
if ((process.env.NODE_ENV === 'production' && stage === 'build-javascript') || options.development) {
actions.setWebpackConfig({
plugins: [
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1
})
]
});
}
};
hi @nsisodiya, would this work for your needs?
exports.onCreateWebpackConfig = () => {
actions.setWebpackConfig({
optimization: {
splitChunks: false,
},
});
};
From what I can tell (I _think_) Gatsby creates an entry file for each of your pages, which will create additional JS files in addition to app.js. This is a separate Webpack step from chunking. So if you have more than one page in your src/pages directory, you will end up with more than one js file even with this setting on. If you keep just one index.js file in src/pages, and use the snippet above, this will get you close to one file for your app.
@trevorlitsey - I tried, but it didn't worked.
As mentioned in your other issue we don't recommend changing this behavior of Gatsby. We work hard on making Gatsby as fast as possible and this would decrease your speed. Hence I'm closing this, thanks for the issue!
@LekoArts what about actually "enhancing" the gatsby config? Is this not recommended when gatsby config does not totally suit us?
For example see this https://github.com/gatsbyjs/gatsby/issues/10965#issuecomment-453456324
Most helpful comment
hi @nsisodiya, would this work for your needs?
From what I can tell (I _think_) Gatsby creates an entry file for each of your pages, which will create additional JS files in addition to
app.js. This is a separate Webpack step from chunking. So if you have more than one page in yoursrc/pagesdirectory, you will end up with more than one js file even with this setting on. If you keep just oneindex.jsfile insrc/pages, and use the snippet above, this will get you close to one file for your app.