Skip to content
This repository was archived by the owner on Mar 17, 2021. It is now read-only.

Can I get module name in filename template placeholders? #144

Closed
SaekiRaku opened this issue Apr 5, 2017 · 4 comments
Closed

Can I get module name in filename template placeholders? #144

SaekiRaku opened this issue Apr 5, 2017 · 4 comments

Comments

@SaekiRaku
Copy link

I set up webpack's entry property like:

{
    entry:{
        about:"path/to/index.js"
    }
}

In index.js, I use html-loader to require html files, And use extract-loader & file-loader to out put html files, such as

require('html/homepage.html');
//NOTICE that the html file name is different to the entry module's name.
//And I need this html file name will same as the entry module name, it will be 'about.html'.

And I want to use the module name (that set up in webpack's 'entry' property) to out put the html files.

maybe it will like:file-loader?name=[module].[ext]!extract-loader!html-loader, and output is "about.html"

So that it will be: module entry js file auto stand for a same name html file.

Thanks for your time.

And my English is awful, so I made a picture so that can make it easier to understand.

Thanks.

artboard

@michael-ciniawsky
Copy link
Member

@ThomasSoloist Did you try file-loader?name=[name].[ext]!extract-loader!html-loader ?

[module] => [name]

@SaekiRaku
Copy link
Author

@michael-ciniawsky I have set the loader in webpack such as file-loader?name=[name].[ext]!extract-loader!html-loader, if I have a 'homepage.html' then it will output 'homepage.html', and it works fine.

But I need the html file name is same as the webpack entry module name when output. Like I require the html file in the entry of 'about' module, then the html file will output with the name of 'about.html'.

Can file-loader do that?

Thanks.

@SaekiRaku
Copy link
Author

@michael-ciniawsky Eh, I have find a same feature request in issue #114 (#114) that we all need to output the files or folders with the name based on entry modules. Should I close this issue? Thank you again.

@michael-ciniawsky
Copy link
Member

@ThomasSoloist Yep I will triage this at #114 then :), please feel free to join discussion there

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants