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.

Not working with cli3 and minimize: true.

See original GitHub issue

Hi. 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:

  1. Use Vue CLI v3.4.0 to create sample vue application. All promts are default. vue create frontend cd frontend

  2. Install vue-custom-element npm install vue-custom-element --save

  3. Add ./components/AxGrid.vue

<template>
  <div>
    <h4>{{ name }}</h4>
  </div>
</template>

<script>
export default {
  props: {
    name: null
  },
  created() {
    console.log('Debug this Vue');
  }
};
</script>
  1. 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');
  1. 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
    }
  }
};
  1. Run npm run build

  2. 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>image </kbd>

If mimize set to false everything works fine -

<kbd>image </kbd>

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
enf644commented, Mar 1, 2019

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!

@app.route('/draw_ax')
async def draw_ax(request):
    return await response.file(
        './dist/static/js/ax-bundle.js',
        headers={'Content-Type': 'application/javascript; charset=utf-8'}
    )
0reactions
karol-fcommented, Mar 1, 2019

@enf644 Glad it work, regards.

Read more comments on GitHub >

github_iconTop 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 >

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