S
S
shasoft2019-03-06 07:44:03
Node.js
shasoft, 2019-03-06 07:44:03

How to write a plugin to insert your files into the build code?

There is a file with some content, you need to insert it into the final js code using the import / require command, but when you insert it, you need to convert it. How to write a plugin for this under Vue Cli 3?
psOf course, you can insert "as is" and then convert it, but I don't want to insert unnecessary data into the code.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
shasoft, 2019-03-06
@shasoft

We write such a plugin file

module.exports = function (source) {
    // Судя по всему нужно для кеширования
    if (this.cacheable) this.cacheable();
    // Трансформация данных файла source
   ...
    // Вернуть трансформированные данные
    return source;
}

And now you can either register this loader in the settings

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question