Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to configure vue in the project to have access to vue sourcemap in the browser #9

Open
tkeer opened this issue Feb 2, 2021 · 5 comments

Comments

@tkeer
Copy link

tkeer commented Feb 2, 2021

Do you have any tip how can I run all these flows in browser, using debugger?

I have tried cloning the vue project and import vue, but no luck!

Why searching around I stumbled on the great repo, do you have any tip how can I do this?
Thanks

@CroMarmot
Copy link

Prepare

Download vue source code and install yarn, then run the command below

yarn # install dep
yarn dev # build dist/vue.js

Node.js Only

write your test code demo.js, example:

const Vue = require('./dist/vue.js');
const obj = {};
obj._data = {x:'x v',y:{z:'z v',v: 1}};
console.log(obj)
Vue.util.defineReactive(obj,'_data');
console.log(obj)

run it

node demo.js

Now your can modify vue source code or demo.js and see what changes

With browser

Do what official web site / official hello world told your but replace the url with your local generated file.

Or follow the step below

create a demo.html and demo.js

<!DOCTYPE html>
<html>
    <header>
        <title></title>
    </header>
    <body>
        <div id="app"></div>
        <script src="./dist/vue.js"></script>
        <script src="./demo.js"></script>
    </body>
</html>
const vueObj = new Vue({
  el: '#app',
  template: '<div><div> y: {{ y }} </div><button @click="updateX(\'qwe\')"> update </button></div>',
  data() {
    return {
      x: '123'
    }
  },
  computed: {
    y(){
      return this.x+'456';
    }
  },
  methods: {
    updateX(v) {
      this.x = v;
    }
  }
})

then open the html with your browser, and modify the code as you like

@tkeer tkeer changed the title How to run vue while to read the code How to configure vue in the project to have access to vue sourcemap in the browser Feb 27, 2021
@CroMarmot
Copy link

Check the package.json and you will see "dev": "rollup ...", and just google the rollup's document, it tells add -m, so run yarn dev -m instead.

@tkeer
Copy link
Author

tkeer commented Mar 2, 2021

Thanks @CroMarmot this is really useful.
Is there any way I can do it module builder (webpack). I tried to do it with yarn dev:esm but webpack generates following error

Syntax Error: Error: Failed to load plugin 'flowtype' declared in 'src/vue/.eslintrc.js': Cannot find module 'eslint-plugin-flowtype'. I have tried globally install this plugin but error is still the same.

Here is how I am importing vue

import Vue from './vue'

@CroMarmot
Copy link

yarn dev:esm works fine on my computer.

2021-03-05 09-32-47 的屏幕截图

@tkeer
Copy link
Author

tkeer commented Mar 5, 2021

This works fine for me too.
Do you receive any webpack error when you import it from 'dist'?

import Vue from './dist'
(I guess webpack will automatically pick vue.runtime.esm.js)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants