Skip to content

如何在webpack中使用DefinePlugin注入全局变量 #1671

@547377507

Description

@547377507

Version

3.0.0-rc.3

Reproduction link

https://jsfiddle.net/547377507/3a8vdjo6/

Steps to reproduce

在配置文件中,这样写在js中始终访问不到config变量,谢谢所有的回答~
config
.plugin('define')
.init((Plugin, args) => {
args.push({ config: JSON.stringify({ name: '789' }) });
console.log(init输出为:${JSON.stringify(args)});
return new Plugin(...args);
})
.tap((args) => {
args.push({ config: JSON.stringify({ name: '456' }) });
console.log(tap输出为:${JSON.stringify(args)});
return args;
});

What is expected?

输出config变量的值

What is actually happening?

输出undefined

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions