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
Inlining imported css doesn't work in watch mode if a leaf component content is changed #74
Comments
Hallo @sahilmob, Thanks for the issue report. |
I cannot reproduce the issue.
Please:
|
@sahilmob |
@webdiscus Initially my workaround was to create a local
I then disabled Please note that I've added |
Why you use the I don't understand what doing your |
Yes you are right l, I use style loader for HMR. Also you are right about the custom plugin. I convert the html into Freemarket template (ftl)and the reason why I don't write it inside the html is that I want to inline js and css, and the ftl syntax breaks html parsing. |
|
Sure. Thanks |
here is the test case for You can use you Your source tempalte: <#import "template.ftl" as layout>
<@layout.registrationLayout displayMessage=true displayInfo=realm.password && realm.registrationAllowed && !registrationDisabled??; section>
<#if section = "styles">
<link rel="stylesheet" href="./scss/styles.scss" />
</#if>
<#if section = "scripts">
<script typo="module" src="./js/main.js"></script>
</#if>
<img src="./images/picture.png" />
</@layout.registrationLayout> the HtmlBundlerPlugin config: new HtmlBundlerPlugin({
filename: '[name].ftl', // <= output filename of template
test: /\.ftl$/, // <= add it to detect *.ftl files
entry: {
index: 'src/index.ftl',
},
// OR entry: 'src/',
js: {
inline: true,
},
css: {
inline: true,
},
preprocessor: false, // <= disable it for processing *.ftl template w/o compilation
}), The generated output template file: <#import "template.ftl" as layout>
<@layout.registrationLayout displayMessage=true displayInfo=realm.password && realm.registrationAllowed && !registrationDisabled??; section>
<#if section = "styles">
<style>...inlined CSS...</style>
</#if>
<#if section = "scripts">
<script>... inlined JS code ...</script>
</#if>
<img src="img/picture.7b396424.png" />
</@layout.registrationLayout> So you don't need additional |
for info: I'm working on the HMR supporting for styles. So, after changes in a SCSS/CSS file, the generated CSS will be updated in the browser without reloading, similar it works in P.S. what is with your test repo for using |
Thanks for your efforts. My repos is private unfortunately. |
you can create a public demo repo with fake data to reproduce your issue. |
Current behaviour
I have and
index.html
that importsindex.jsx
which has aLayout
Component, and theLayout
Component imports a stylesheet from a package innode_modules
, and theLayout
component renders a child component, when I runwebpack --watch --progress --mode development
for the first time I get all the js and css injected in the html however, if I change the child component file and save, the generated html won't have the inline css, furthermore, if I go to theLayout
component and save it to trigger rebuild, I get the css in the generated html.Expected behaviour
The css should be included in the generated html in watch mode every time
Reproduction Example
./index.html
./index.js
./Layout.jsx
./SomeComponent.jsx
webpack.config.js
Environment
Additional context
I noticed that the
beforeEmit
hook isn't being called after savingSomeComponent
while its being called forLayout
componentThe text was updated successfully, but these errors were encountered: