-
-
Notifications
You must be signed in to change notification settings - Fork 384
New option: EmitFile, similar to file-loader to allow for the plugin ***not*** to emit the assets #713
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
Would also satisfy #74, an older version of this same request that was abandoned back |
You can just ignore CSS files using |
I would need to study that alternative to ensure it is accurate but, for the sake of continuity I'll just assume it is correct. With that said I don't think it solves the use case being put forward here. The idea with the proposed functionality (in a similar way with the way it worked for the file-loader equivalent option) is:
If necessary for the PR to be considered I can construct the use case where Should I proceed pleading the case or there is a bigger issue here preventing the new option from being considered? |
Please provide case |
An usecase was prepared at ferdinando-ferreira/mini-css-extract-plugin Instructions to test
The example chosen was what is essentially the "Hello World" of vue when used with Single File Components. That project uses and endorses this plugin as the means to extract css to their own files and, consequently, provides with a very good usecase for the proposed option. The source code being packed is not really important:
It has a peculiarity tho: App.vue can contain css, be it by having it inline in the The mini-css-extract-plugin is used here as a "catch-all", extracting from the javascript all of the generated css created by the interactions of these Single File Components and creating their own files. Enters SSR: from the exact application two packed files are generated: one for use in the browser (let's call it index.js) and one for use in the server (index-ssr.js). This is made possible by compiling the exact same application with two webpack configurations, one for the client and one for the server. usecase/config/webpack.config.js
The difference between the client and the server configuration are highlighted below, assuming the emitFile option in the plugin exists. usecase/config/webpack.config.client.js
usecase/config/webpack.config.server.js
|
(continuing) In the SSR case, despite being important to extract out the styles from the code (to reduce the size of the resulting file) it is also important to not generate the extracted file, as it has no use server side. Likely because of not having experience with Can you show a way to achieve the same goal with |
You already do not extract styles for SSR: 'use strict'
module.exports = [
// require('./webpack.config.client.js'),
require('./webpack.config.server.js')
] Output:
For client you need extract CSS because without it styles will not work |
Thanks for acknowledging the proposed PR would solve the issue, because the reason it "already do not extract styles for SSR" is because the use case already uses the plugin with the usecase/config/webpack.config.server.js#L27-L30
To clarify the point I prepared a second use case, this time using the plugin as it exists right now. Instructions to test:
You will notice that, unlike in the example using the modified plugin with the
Which is the exact issue motivating the PR and the reason I request this issue to be reopened and the PR reconsidered. Here is the summary:
You mentioned using P.S. pinging @alexander-akait because I don't really know closed issues still send notifications |
@alexander-akait: I'll retract the PR for now and submit a new issue and a new PR better explained and passing all tests |
@ferdinando-ferreira just don't use this plugin for SSR, i.e.: {
test: /\.css$/,
use: [
{ loader: "vue-style-loader" },
{ loader: "css-loader" }
]
} |
@alexander-akait: that wouldn't work because
|
In this case you need extract, otherwise manifest still be different
No, double check |
@alexander-akait: you are correct, it does not generate a separate See #722, resubmitted the PR, now passing the commit lint, please continue discussion there. |
Feature Proposal
Addition of the option emitFile, similar to the one existing in other plugins like file-loader (see: https://webpack.js.org/loaders/file-loader/#emitfile
Feature Use Case
Much like in the file-loader use case, it allows for the resource to be extracted from the javascript (reducing its size) without actually creating the resource on disk, useful to when a SSR version of the javascript file is being generated
The text was updated successfully, but these errors were encountered: