0

When I created chunk with the help of CommonChunkPlugin, extract-text-webpack-plugin doesn`t extract css from landings chunk. Any ideas?

config: {
plugins: [
    new webpack.optimize.CommonsChunkPlugin({
        chunks: [
            'vzr',
            'vzrProduct',
            'emptyProduct'
        ],
        async: 'landings'
    }),
    new ExtractTextPlugin({
        filename: '[name].[contenthash].css',
        allChunks: true
    })
  ]
}
1
  • Have you tried plugins: [ ... ] instead of plugins: { ... }? Commented Nov 28, 2017 at 19:49

2 Answers 2

1

Javascript Objects must have a key and value separated by a colon. In your case, you have plugins: {} and inserting to this a series of functions, which we may call keys, but that are not followed by a colon and a value but a comma.

According to this plugins are not an object but an array of values. So, instead of:

config: {
  plugins: {
    new webpack.optimize.CommonsChunkPlugin({
      chunks: [
        'vzr',
        'vzrProduct',
        'emptyProduct'
      ],
      async: 'landings'
  }),
  new ExtractTextPlugin({
    filename: '[name].[contenthash].css',
    allChunks: true
  })
}

}

Rather:

config: {
  plugins: [
    new webpack.optimize.CommonsChunkPlugin({
      chunks: [
        'vzr',
        'vzrProduct',
        'emptyProduct'
      ],
      async: 'landings'
    }),
    new ExtractTextPlugin({
      filename: '[name].[contenthash].css',
      allChunks: true
    })
  }
]
Sign up to request clarification or add additional context in comments.

1 Comment

Please post it as an answer so that somebody else who runs into the same problem may get help
0

I added the function into minChunk and problem is solved. CommonChunkPlugin stopped to extract css and less modules

config: {
plugins: [
    new webpack.optimize.CommonsChunkPlugin({
        chunks: [
            'kaskoLanding',
            'kaskoLandingProduct',
            'kaskoCalculator',
            'kaskoCalculatorProduct',
            'osagoCalculator',
            'osagoCalculatorProduct',
            'vzr',
            'vzrProduct',
            'emptyProduct'
        ],
        minChunks: (module, count) => {
            if (module.resource && (/^.*(css|less)$/).test(module.resource)){
                return false;
            }

            return count >= 9;
        },
        async: 'landings'
    }),
    new ExtractTextPlugin({
        filename: '[name].[contenthash].css',
        allChunks: true
    })
]

}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.