style-loader-insert-top
v1.0.0-alt.1
Published
Custom webpack style-loader insert function to inject style tags to the top of the head element
Readme
style-loader-insert-top
Custom webpack style-loader insert function to inject style tags to the top of the head element.
This package simply packages the insert function example from webpack's style-loader documentation. Instead of copying the function into your project, you can use this package directly.
Why?
By default, style-loader appends <style> elements to the end of the <head> tag. This means your bundled styles will override any existing stylesheets. Sometimes you want the opposite behavior - inserting styles at the top so they can be overridden by existing stylesheets or inline styles.
Usage:
module.exports = {
module: {
rules: [
{
test: /\.css$/i,
use: [
{
loader: "style-loader",
options: {
insert: require.resolve('style-loader-insert-top')
},
},
"css-loader",
],
},
],
},
};Install
npm install style-loader-insert-topLicense
MIT
