Why would you want to use the runtime-only build inside browsers?
Are you sure you don't need template/jsx compilation and just want to write all render functions by hand?
I have my build system configured with support for .vue files and jsx, and both of them don't use the template option.
Since you do have a build system, why not just use runtime-only build with it, instead of loading vue separately in browser?
I just don't want one single big bundled file. It would be better if I just load frameworks and libraries separately from my code.
In webpack there is CommonsChunkPlugin, but I'm using Rollup here :/
@NicolasParada As a fix, add a script tag that adds process.env.NODE_ENV to the global namespace:
<script>
window.process = { env: { NODE_ENV: 'production' } }
</script>
<script src ="https://unpkg.com/[email protected]/dist/vue.common.js" />
@fnlctrl I'm not sure weither these variables are supposed to be present in a build on a CDN. At least it's inconvenient to offer CDN access to these files and then require a workaround like above to use them.
Think we should discuss internally how to deal with this.
I think the runtime only is meant to be used with a bundler. If you're using rollup you can use https://github.com/rollup/rollup-plugin-replace
@LinusBorg module.exports gave problems too...
@posva Yeah, there is a couple of solutions, but... since they are on a CDN, they should be browser ready; with a minified version too.
@NicolasParada They're automatically added to CDNs so it's normal for some of them not to be browser ready and/or without a minified version
I wanted to start using the CDN version of vue inside a Rails app today and met the same issue. Building upon @LinusBorg & @NicolasParada input, here is the version that works for me:
<script type="text/javascript">
window.process = { env: { NODE_ENV: 'production' } };
window.module = {};
</script>
I wonder if there's a version hosted somewhere which can be used without any tweak?
When next release is out you can use the UMD runtime build via https://unpkg.com/vue/dist/vue.runtime.js
when I change vue.common.js to vue.min.js,problem solved.however,I still don't understand why.
Most helpful comment
@LinusBorg
module.exportsgave problems too...@posva Yeah, there is a couple of solutions, but... since they are on a CDN, they should be browser ready; with a minified version too.