Daniel_L February 2016

Multiple entry points without common chunks or dynamic loading

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?

Answers


ssube February 2016

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.

Post Status

Asked in February 2016
Viewed 1,266 times
Voted 14
Answered 1 times

Search




Leave an answer