-
-
Notifications
You must be signed in to change notification settings - Fork 384
[path] placeholder #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This doesn't make sense. What's you use case for this? |
If I do this:
import "../styles/main.scss"; ... the CSS file is saved to This is similar to #67, and if that function has enough data in the arguments provided, it might be a viable alternative. Either that, or CSS entrypoints 😛 (related) PS. I'm new to webpack, so if I'm missing something obvious, please excuse me. |
I should have mentioned, I use paths for my chunk names, and not simple names like "page1". By using: entry: {
"scripts/main": "./scripts/main.ts",
// more
} My JavaScript files are written to subdirectories of the output path (when using If a JS file references a CSS file, and the mini-css-extract-plugin filename template is set to However, I (and I'm sure others) need to be able to write the CSS to a path based on its actual path on disk (in the src). Either in the form of additional placeholders (this issue), or via a filename function (#67) that is called with enough context to extract that data. The data seems to be available under My use case is a multi-page website, where the server-rendered templates (PHP/Twig) should be able to reference an asset using its source path, which then returns the relevant path(s) in the output directory. For example, if the template asks for Hopefully this makes some sense. It's really about maintaining the directory structure of CSS files, instead of putting them together with the JavaScript. Edit: CSS modules as entry points would probably be a better/cleaner solution, but it might be a long time before that is available and stable. |
I answered that as best I could, with two detailed explanations. What is the status of the CSS modules support that you were working on? |
Yes I understand, but for a extracted CSS chunk/file which modules Asset path generation is roughly working in the following way // compiler.options.output.path === config.output.path (webpack.config.js)
const name = options.filename || chunk.name
const asset = compiler.options.output.path + name
compilation.assets[asset] = new RawSource(css) |
Well the PR is very rough atm, all the postcss plugins used there need to be extracted and I need to rebase. It work(ed) for the usual case but |
I think I understand what you're saying. If a JS file references I think what I actually need(ed) is CSS entrypoints, which (AFAIK), don't really work properly at this stage. If I understand correctly, first-class support for CSS modules would make this a lot easier. Something like this would also be cool. (HTML entry files)
Thanks for the update. It would be nice if this page could be updated to remove the |
Exactly, e.g the
const config = {
output: {
path: {
'.js': 'dist',
'.css': 'dist/styles'
}
}
} would be better and possible, if CSS is a first class citizen 😛
😆 I wrote my own bundler for learning proposes and it is based on exactly that idea, it is soooo much easier if you use an HTML File as the entrypoint and opens the door for MPA (Multi-Page Applications)* nearly naturally, while SPA (webpack's bread and butter (many JS Entries + *
It also partially implemented already in the PR I made to webpack for HTML (not sure if I pushed the lateest code there, but I used it already (locally) 😛)
The problem as with CSS is that again with all possible configs webpack supports atm (which are specific to having JS as an entrypoint), this requires more work to function properly in
😯 Ohh I don't now what's the status of the voting page to be honest, but it is still is kind of in progress as we continued to work on some CSS related stuff. I also may continue these PR's in the near future :) |
[name]
returns the name of the chunk that imports the CSS file, from what I understand. I need to get the name/path of the imported CSS file.The file-loader has a
[path]
placeholder that returnsThe path of the resource relative to the context
. Is it possible to add something similar to this plugin?(either that, or add this information to the filename function)
The text was updated successfully, but these errors were encountered: