没有公共块或动态加载的多个入口点

时间:2016-02-08 16:57:59

标签: javascript webpack

我正在制作一个chrome扩展程序,它承载多个应用程序(多个devtools面板),每个应用程序都是独立的。我需要webpack来观察多个入口点并生成多个bundle,我不需要常见的块。我绝对不想在客户端代码like this中使用amd。

/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]

所以我猜你不能在[name]设置中为多个条目设置path变量?

1 个答案:

答案 0 :(得分:8)

您应该在文件名字段中使用[name]而不是路径。查看文档,filename lists the [name] variablepath does not(仅显示[hash])。

你会使用类似的东西:

{
  path: path.join(__dirname, 'chrome'),
  filename: '[name]/bundle.js'
}

文档没有明确说明filename可以有多个路径段,只是说filename不能是绝对路径。