https://github.com/agrublev/cssloader
Loading css like modules
https://github.com/agrublev/cssloader
Last synced: over 1 year ago
JSON representation
Loading css like modules
- Host: GitHub
- URL: https://github.com/agrublev/cssloader
- Owner: agrublev
- License: mit
- Created: 2017-01-18T05:06:52.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-08-18T14:59:42.000Z (almost 9 years ago)
- Last Synced: 2025-02-15T06:41:26.006Z (over 1 year ago)
- Language: CSS
- Size: 1.86 MB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
Load by using
```javascript
docReady(function() {
// require some stylesheets
cssloader.require([
{href: "/fcloader/stylesheets/style1.css", media: "screen"},
{href: "stylesheets/style2.css", media: "screen"},
{href: "stylesheets/style5.css", media: "screen"}
], {devMode: true});
});
// Alternatively with jquery
$(function(){
// require some stylesheets
cssloader.require([
{href: "/fcloader/stylesheets/style1.css", media: "screen"},
{href: "stylesheets/style2.css", media: "screen"},
{href: "stylesheets/style5.css", media: "screen"}
], {devMode: true});
});
```
Compile less
Compile multiple css to one file
Load css using if on same domain checked
var client = new XMLHttpRequest();
client.open('GET', '/foo.txt');
client.onreadystatechange = function() {
alert(client.responseText);
}
client.send();
Load based on url parameter
// webpack.config.js
var ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = {
// The standard entry point and output config
entry: {
posts: "./posts",
post: "./post",
about: "./about"
},
output: {
filename: "[name].js",
chunkFilename: "[id].js"
},
module: {
loaders: [
// Extract css files
{
test: /\.css$/,
loader: ExtractTextPlugin.extract("style-loader", "css-loader")
},
// Optionally extract less files
// or any other compile-to-css language
{
test: /\.less$/,
loader: ExtractTextPlugin.extract("style-loader", "css-loader!less-loader")
}
// You could also use other loaders the same way. I. e. the autoprefixer-loader
]
},
// Use the plugin to specify the resulting filename (and add needed behavior to the compiler)
plugins: [
new ExtractTextPlugin("[name].css")
]
}
(c) 2015 MIT License