6

I want to connect this toastr-library into my component:

my-component.vue

<script>
  import toastr from 'toastr';

  export default {
    mounted(){
      toastr.success('Hello from toastr!');
    }
  }
</script>

<template>
  <div>
    Template for my-component.vue here.
  </div>
</template>


<style>
  /* HOW TO IMPORT `toastr.css` FROM NODE_MODULES HERE?
</style>

How to connect library's css from node_modules directory?

1

1 Answer 1

13

As @LinusBorg suggested here in vue-loader discussion thread, you can use src-attribute inside <style>-tag:

my-component.vue

<script>
  import toastr from 'toastr';

  export default {
    mounted(){
      toastr.success('Hello from toastr!');
    }
  }
</script>

<template>
  <div>
    Template for my-component.vue here.
  </div>
</template>


<style src='toastr/build/toastr.min.css'></style>
Sign up to request clarification or add additional context in comments.

2 Comments

yup its work: <style src='../../node_modules/@toast-ui/editor/dist/toastui-editor.css'></style> <style scoped></style>
Should also work without node_modules simply with toast-ui/editor/dist/toastui-editor.css.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.