3

I'm making a chrome extension that hosts multiple applications (multiple devtools panels), each one independent. I need webpack to watch multiple entry points and produce multiple bundles, I don't need common chunks. I definitely do not want to use amd in the client side code 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...

As per docs on multiple entries I've been doing:

{
    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
    }
}

I get the error:

Path variable [name] not implemented in this context: C:\Users\Admin\projects\crx\chrome\[name]

So I guess you cannot have the [name] variable in the path setting for multiple entries?

Community
  • 1
  • 1
Daniel Lizik
  • 3,058
  • 2
  • 20
  • 42
  • I think `[name]` needs to be in the filename rather than the path, i.e. `{path: path.join(__dirname, 'chrome'), filename: '[name].bundle.js'}` – ssube Feb 08 '16 at 16:59
  • Yes, but then how can I specify a dynamic path for each output? That is, I don't want all bundles to be in the same folder. – Daniel Lizik Feb 08 '16 at 16:59
  • 1
    Oh wow you are right, i just did `[name]/bundle.js` instead, my god. – Daniel Lizik Feb 08 '16 at 17:00

1 Answers1

9

You should use [name] in the filename field instead of path. Looking at the docs, filename lists the [name] variable and path does not (only showing [hash]).

You would use something like:

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

The documentation does not explicitly state the filename can have multiple path segments, it only says the filename must not be an absolute path.

ssube
  • 47,010
  • 7
  • 103
  • 140