Not working with cli3 and minimize: true.
See original GitHub issueHi. First of all i want to thank @karol-f for your hard work on this repo. I think it is better then vue-web-component-wrapper. (I suggest you remove link to it from README.md, or at least move to bottom ).
I found that vue-custom-element is not working while minified by Vue Cli3.
Steps to reproduce:
-
Use Vue CLI v3.4.0 to create sample vue application. All promts are default.
vue create frontend
cd frontend
-
Install vue-custom-element
npm install vue-custom-element --save
-
Add ./components/AxGrid.vue
<template>
<div>
<h4>{{ name }}</h4>
</div>
</template>
<script>
export default {
props: {
name: null
},
created() {
console.log('Debug this Vue');
}
};
</script>
- Modify ./main.js to register web-component
import Vue from 'vue';
import App from './App.vue';
import vueCustomElement from 'vue-custom-element';
import AxGrid from './components/AxGrid.vue';
Vue.use(vueCustomElement);
Vue.config.productionTip = false
Vue.customElement('ax-grid', AxGrid);
new Vue({
render: h => h(App),
}).$mount('#app');
- Create ./vue.config.js . I need to create single file bundle.
module.exports = {
outputDir: './../dist',
css: {
extract: false
},
configureWebpack: {
output: {
filename: 'static/js/ax-bundle-test.js'
},
optimization: {
splitChunks: false,
minimize: true
}
}
};
-
Run
npm run build
-
Include ax-bundle-test.js to independent html page.
<script type="text/javascript" src="http://127.0.0.1:8080/static/js/ax-bundle-test.js"></script>
<h1>Web components are working! :</h1>
<ax-grid name='hohoh'></ax-grid>
Unfortunately i get error - <kbd> </kbd>
If mimize set to false everything works fine -
<kbd> </kbd>
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Vue CLI 3 remove console.log and code comments with Terser
First of all: make sure you are configuring Terser correctly: terserOptions: { ecma: 6, compress: { drop_console: true }, output: ...
Read more >Vue cli 3.0.0 vue config Minimize / Compress false is being ...
My minimize false config option is still producing minimized js file when build command is used. Is there something i am doing worng...
Read more >[Vue warn]: You are using the runtime-only build of ... - GitHub
Hey, I'm using ant-design-vue and vue-router, this problem came up when I try to use router-view. adding vue.config.js file doesn't help me out...
Read more >How to drastically reduce your bundle size and load time in ...
Lazy loading can significantly reduce your bundle size. Everything that is not required on the initial render should be lazy loaded.
Read more >How to make lazy loading actually work in Vue (CLI 3) - Medium
What was happening was that the code was being splitted, yes, but every chunk was being loaded at page load time, and not...
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
I was able to solve this problem. Indeed it was not related with vue-custom-element.
I am very sorry for your time. Thank you for helping me solve this puzzle.
The problem was with python-backend that was serving the bundle.js. (Sanic) It could not detect right content-type for minified version. I forced utf-8 javascript content-type and everything started working!
@enf644 Glad it work, regards.