Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
css-hot-loader
Advanced tools
This is a css hot loader, which supprot hot module replacement for an extracted css file.
In most cases, we can realize css hot reload by style-loader . But style-loader need inject style tag into document, Before js ready, the web page will have no any style. That is not good experience.
Also, a lots of people thought about that, How can realize hot reload with extract-text-webpack-plugin. For example #30 , #!89.
So I write this loader, which supprot hot module replacement for an extracted css file.
First install package from npm
$ npm install css-hot-loader --save-dev
Then config webpack.config.js
module: {
loaders: [{
test: /\.less$/,
loaders: [
'css-hot-loader',
'extract-text-webpack-plugin',
'less',
...
],
include: path.join(__dirname, 'src')
}]
}
css-hot-loader
should be the first loader before extract-text-webpack-plugin
.
Config file example should like this
module: {
rules: [
{
test: /\.css$/,
use: ['css-hot-loader'].concat(ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader'
})),
},
]
}
The realization principle of this loader is very simple. There are some assumed condition:
The secend assumption is often established. If you use extract-text-webpack-plugin , entry foo.js
will extract css file foo.css
. This principle will help us to locate the url of css file extracted.
Because every css file will be a js module , every css file change can affect a module change. CSS hot loader will accept this kind change, then find extracted css file by document.currentScript
.
So when a css file changed, We just need find which css file link element, and reload css file.
(The MIT License)
FAQs
css hot reload work with extract-text-webpack-plugin
The npm package css-hot-loader receives a total of 18,655 weekly downloads. As such, css-hot-loader popularity was classified as popular.
We found that css-hot-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.