Skip to content

How can I have code splitting? #90

Answered by brenogazzola
flivni asked this question in Q&A
Discussion options

You must be logged in to vote

Just need to adjust Webpack's configuration file. Remove the LimitChunkCountPlugin and add the chunkFilename attribute to tell it to predigest the chunks and add .digested. This last keyword will indicate Sprockets that it should not add another digest to the file when running precompile.

const path    = require("path")
const webpack = require("webpack")

module.exports = {
  mode: "production",
  devtool: "source-map",
  entry: {
    application: "./app/javascript/application.js"
  },
  output: {
    filename: "[name].js",
    chunkFilename: '[name]-[contenthash].digested.js',
    sourceMapFilename: "[name].js.map",
    path: path.resolve(__dirname, "app/assets/builds"),
  }
}

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@justin808
Comment options

Answer selected by dhh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants