Y
Y
yeco2021-12-13 19:44:49
webpack
yeco, 2021-12-13 19:44:49

How to use webpack.DefinePlugin.runtimeValue?

Hello, I want to be able to write in index.html like this

<% VUE_APP_ADD_INLINE("style", "body{background:green}" ) %>

and so that it compiles I'm trying to do it by writing
<style>body{background:green}</style>
VUE_APP_ADD_INLINE: webpack.DefinePlugin.runtimeValue(function (tag, code) {
           return JSON.stringify("<" + tag + ">" + code + "</" + tag + ">");
        }, []),

in WebpackDefinePlugin but I get
Template execution failed: TypeError: "<[object Object]>undefined</[object Object]>" is not a function

  TypeError: "<[object Object]>undefined</[object Object]>" is not a function

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
yeco, 2021-12-15
@yeco

For such compiler functions, you can use
TempleteParameters in htmlWebpackPlugin

templateParameters: {
        HELLO_WORLD: function (data) {
             return "hello world" + data;
          }
        },

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question