我正在制作一个托管多个应用程序(多个开发工具面板)的 chrome 扩展,每个应用程序都是独立的。我需要 webpack 来监视多个入口点并生成多个包,我不需要公共(public) block 。我绝对不想在客户端代码中使用 amd like this .
/appOne
index.js
/components
/blah
/foobar
/appTwo
index.js
/components
..etc
/appThree
index.js
/components
..etc.
/chrome <- basically the "dist" folder
/appOne
index.html
bundle.js
/appTwo
index.html
bundle.js
/appThree
etc...
根据我一直在做的关于多个条目的文档:
{
entry: {
appOne: './appOne/index.js',
appTwo: './appTwo/index.js'
},
output: {
path: path.join(__dirname, 'chrome', '[name]'),
filename: 'bundle.js' //can be the same since they should be output in different folders
}
}
我得到错误:
Path variable [name] not implemented in this context: C:\Users\Admin\projects\crx\chrome\[name]
所以我猜你不能在 path
设置中为多个条目设置 [name]
变量?
最佳答案
您应该在文件名字段中使用 [name]
而不是路径。查看文档,filename lists the [name]
variable和 path does not (仅显示 [hash]
)。
你会使用类似的东西:
{
path: path.join(__dirname, 'chrome'),
filename: '[name]/bundle.js'
}
文档没有明确说明filename
可以有多个路径段,它只是说filename
不能是绝对 路径。
关于javascript - 没有公共(public) block 或动态加载的多个入口点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35275051/