R
R
resibe2021-11-18 19:54:55
webpack
resibe, 2021-11-18 19:54:55

How to use WebpackDefinePlugin to be used in other plugins?

Hello, I need to do something like

module.exports = defineConfig({
configureWebpack: {
plugins: [

new webpack.DefinePlugin({
        APP_NAME: JSON.stringify("myApp"),
      }),
new HtmlWebpackPlugin({
        title: APP_NAME + " official"
})

]
}
});

since modules are exported at the same time, defines inside them do not work, which analog can be used

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aetae, 2021-11-18
@resibe

Separate constants? 0_o

const {APP_NAME} = require('./constants');

new webpack.DefinePlugin({
        APP_NAME: JSON.stringify(APP_NAME),
      }),
new HtmlWebpackPlugin({
        title: APP_NAME + " official"
})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question