question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CommonsChunkPlugin not work with require in .vue files

See original GitHub issue

I import moment module in 3 .vue files, but moment didn’t be generated in vendor.js

https://github.com/hanai/test

jj

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
LinusBorgcommented, Feb 22, 2017

That is working as expected. Since all 3 of your route components require moment.js, and its up to the visitor to decide which route to go to first, webpack has to put it into each of the async bundles.

if you want to extract dependencies that are shared amongst your extractred asynv bundles, you have to create another instance of the commonChunks Plugin:

I think it should look like this:

javascript
plugins: [
 // other plugins...,
  new webpack.optimize.CommonsChunkPlugin({
    name: 'commonsasync.js',
    async; 'commonsasync',
    min: 2,
  })
]

Coincidentally, I learned about this just yesterday through this article:

https://medium.com/@adamrackis/vendor-and-code-splitting-in-webpack-2-6376358f1923#.jyz1nf7v2

…and haven’t tested it. Try it out and see if that works as intended.

0reactions
LinusBorgcommented, Feb 23, 2017

@hanai If that solves your problem, please consider closing this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

vue-cli & webpack 4: CommonsChunkPlugin · Issue #1421
I am struggling with this problem too. npm run build does not work. I can not find how to update the webpack.prod.conf.js file...
Read more >
Uncaught ReferenceError: webpackJsonp in Vue Js
I have suddenly started hitting Uncaught ReferenceError: webpackJsonp in Vue Js. I am fairly new to Js and have just started with Vue ......
Read more >
Issue using webpack CommonsChunkPlugin for multiple ...
Coding example for the question Issue using webpack CommonsChunkPlugin for multiple entries-Vue.js.
Read more >
4 Ways To Boost Your Vue.js App With Webpack | Codementor
Webpack is an essential tool for VueJS apps, but is notoriously hard ... will need to be in separate files, making them hard...
Read more >
Webpack config help - console error - JavaScript - SitePoint
Basically I use VueJS, so main point is use .vue extension files ... I don't have any kind of special config, but it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found