dayjs-module icon indicating copy to clipboard operation
dayjs-module copied to clipboard

Registering a local plugin

Open laventnc opened this issue 3 years ago • 0 comments

I have defined a plugin to add a function to the $dayjs() object:

// plugins/dayjs.js
export default (option, dayjsClass) => {
  dayjsClass.prototype.addWeekdays = function (numDays) {
    const direction = numDays < 0 ? -1 : 1
    let date = this
    while (numDays !== 0) {
      date = date.addDays(direction)
      if (date.day() !== 0 && date.day() !== 6) {
        numDays -= direction
      }
    }
    return date
  }
}

However, when using the plugins setting plugins: ['~/plugins/dayjs.js'] the module cannot be found because it looks within 'dayjs/plugin/~/plugins/dayjs`

laventnc avatar Aug 31 '22 14:08 laventnc