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.

Creating a single js file build

See original GitHub issue

Version

3.0.0-beta.2

Reproduction link

https://jsfiddle.net/b1jn7rv6/

Steps to reproduce

With vue-cli v2.9.3 I created a single js file build with uncommenting all the new webpack.optimize.CommonsChunkPlugin functions in ./build/webpack.prod.conf.js file.

How I can achieve the same with vue-cli v3? I tried this config, but doesn’t work:

// vue.config.js
module.exports = {
  lintOnSave: true,
  chainWebpack: (config) => {
    config
      .plugin('split-vendor')
      .clear();
  },
  productionSourceMap: false,
};

What is expected?

Creating a single js file build.

What is actually happening?

Error is returned, build not created:

$ npm run build

> vue-test-package@0.1.0 build D:\www\node\vue-cli\vue-test-package
> vue-cli-service build


-  Building for production...D:\www\node\vue-cli\vue-test-package\node_modules\webpack-chain\src\Plugin.js:38
    return init(this.get('plugin'), this.get('args'));
           ^

TypeError: init is not a function
    at Object.toConfig (D:\www\node\vue-cli\vue-test-package\node_modules\webpack-chain\src\Plugin.js:38:12)
    at clean.Object.assign.plugins.plugins.values.map.plugin (D:\www\node\vue-cli\vue-test-package\node_modules\webpack-chain\src\Config.js:69:59)
    at Array.map (<anonymous>)
    at module.exports.toConfig (D:\www\node\vue-cli\vue-test-package\node_modules\webpack-chain\src\Config.js:69:38)
    at Service.resolveWebpackConfig (D:\www\node\vue-cli\vue-test-package\node_modules\@vue\cli-service\lib\Service.js:142:34)
    at PluginAPI.resolveWebpackConfig (D:\www\node\vue-cli\vue-test-package\node_modules\@vue\cli-service\lib\PluginAPI.js:119:25)
    at api.registerCommand.args (D:\www\node\vue-cli\vue-test-package\node_modules\@vue\cli-service\lib\commands\build\index.js:86:27)
    at Service.run (D:\www\node\vue-cli\vue-test-package\node_modules\@vue\cli-service\lib\Service.js:130:28)
    at Object.<anonymous> (D:\www\node\vue-cli\vue-test-package\node_modules\@vue\cli-service\bin\vue-cli-service.js:22:9)
    at Module._compile (module.js:662:30)
    at Object.Module._extensions..js (module.js:673:10)
    at Module.load (module.js:575:32)
    at tryModuleLoad (module.js:515:12)
    at Function.Module._load (module.js:507:3)
    at Function.Module.runMain (module.js:703:10)
    at startup (bootstrap_node.js:193:16)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

34reactions
diogosalazarcommented, Jun 21, 2018

@rowej83

I think setting the splitChunks option in webpack to false should take care of that:

// vue.config.js
module.exports = {
  configureWebpack: {
    // No need for splitting
    optimization: {
      splitChunks: false
    }
  }
}
18reactions
rowej83commented, May 23, 2018

Can we get a clear example of what a vue.config.js would consists of to build to a single js file? I know it’s better for caching reasons but I know I’m not the only one who would like to know this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Simplest way to compile all TypeScript into one single Js file ...
It'll convert all TypeScript files that are inside "src" folder and output them in the "dist" folder. Step 1: Create a Simplest project....
Read more >
Is there a way to build single js file without external libs? - Reddit
Trying to build application using WebStorm built in compiler and tsconfig.json I'm almost happy with results, getting single file with all ...
Read more >
How can I create a build from a JavaScript file based on node ...
It sounds like you want to create a single executable artifact which requires no server-side configuration or setup to run.
Read more >
Build lit into a single javascript file - gists · GitHub
Build lit into a single javascript file. GitHub Gist: instantly share code, notes, and snippets.
Read more >
A Whole Website in a Single JavaScript File?! - YouTube
In this video, let's dig in and understand the infrastructure of Demo. Tune in to this video till the end to understand better...
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