Creating a single js file build
See original GitHub issueVersion
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:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@rowej83
I think setting the
splitChunks
option in webpack tofalse
should take care of that: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.