Feb 1, 2023
0
Level 2
how can I add custom logic to the vue-template-compiler in laravel-mix?
I'm trying to add some custom logic to the template compiler here is my code
const mix = require("laravel-mix");
mix.extend("myPlugin", function (src, output, options) {
mix.webpackConfig({
module: {
rules: [
{
test: /\.vue$/,
use: [
{
loader: "vue-loader",
options: {
compiler: require("vue-template-compiler"),
compile: function (template, options) {
console.log("++++++++++++++++++++++++");
console.log(template);
console.log("++++++++++++++++++++++++");
// Modify the template code here
return template;
}
}
}
]
}
]
}
});
return mix.webpackConfig();
});
and my build method like this
mix
.jigsaw()
.js("source/_assets/js/main.js", "js")
.myPlugin()
.sass("source/_assets/scss/main.scss", "css")
.sass("source/_assets/scss/cf-errors/main.scss", "css/cf-errors/")
but nothing logging in the console, I think it's not applying the compile method. What I'm missing here?
Please or to participate in this conversation.