javascript - Multiple entry points without common chunks or dynamic loading - Stack Overflow

I'm making a chrome extension that hosts multiple applications (multiple devtools panels), each on

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 mon chunks. I definitely do not want to use amd in the client side code like this.

/appOne
    index.js
    /ponents
        /blah
        /foobar
/appTwo
    index.js
    /ponents
        ..etc
/appThree
    index.js
    /ponents
        ..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?

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 mon chunks. I definitely do not want to use amd in the client side code like this.

/appOne
    index.js
    /ponents
        /blah
        /foobar
/appTwo
    index.js
    /ponents
        ..etc
/appThree
    index.js
    /ponents
        ..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?

Share Improve this question edited May 23, 2017 at 12:34 CommunityBot 11 silver badge asked Feb 8, 2016 at 16:57 Daniel LizikDaniel Lizik 3,1442 gold badges23 silver badges44 bronze badges 3
  • 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 Commented Feb 8, 2016 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 Commented Feb 8, 2016 at 16:59
  • 1 Oh wow you are right, i just did [name]/bundle.js instead, my god. – Daniel Lizik Commented Feb 8, 2016 at 17:00
Add a ment  | 

1 Answer 1

Reset to default 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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745565872a4633389.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信