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

Dan*_*zik 3 javascript webpack

我正在制作一个chrome扩展程序,它包含多个应用程序(多个devtools面板),每个应用程序都是独立的.我需要webpack来观察多个入口点并生成多个bundle,我不需要常见的块.我绝对不希望在客户端代码中使用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...
Run Code Online (Sandbox Code Playgroud)

根据我一直在做的多个条目的文档:

{
    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
    }
}
Run Code Online (Sandbox Code Playgroud)

我收到错误:

Path variable [name] not implemented in this context: C:\Users\Admin\projects\crx\chrome\[name]
Run Code Online (Sandbox Code Playgroud)

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

ssu*_*ube 8

您应该[name]在filename字段而不是path中使用.查看文档,文件名列出[name]变量,路径不列出(仅显示[hash]).

你会使用类似的东西:

{
  path: path.join(__dirname, 'chrome'),
  filename: '[name]/bundle.js'
}
Run Code Online (Sandbox Code Playgroud)

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