Skip to content
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

Update readme.md with webpack example code #515

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,95 @@ The API is documented in Sass, but we've worked hard to make the API *very* simi

Explore [Official Integrations](docs/integrations) to see some community-backed plugins to your favorite frameworks and libraries.

#### Webpack Users

Please find an example of a working webpack configuration for stylus below. Make sure to **NOT** include `@import "jeet"` in your .styl-files with this setup.

```javascript
// file: example.styl
// note that you should NOT include jeet with @import "jeet"
body {
div {
color: tint(#000, 42%);
}
}
```

```javascript
// file: package.json
{
"name": "stylus-test",
"version": "1.0.0",
"description": "",
"main": "webpack.config.js",
"scripts": {
"build": "webpack --progress -config webpack.config.js"
},
"author": "",
"license": "MIT",
"dependencies": {
"jeet": "^7.0.0",
"webpack": "^1.13.2",
"style-loader": "^0.13.1",
"css-loader": "^0.25.0",
"stylus": "^0.54.5",
"stylus-loader": "^2.3.1",
"extract-text-webpack-plugin": "^1.0.1"
}
}
```

```javascript
// file: webpack.config.js
var path = require('path');
var webpack = require('webpack');

// extract text into separate files
var ExtractTextPlugin = require('extract-text-webpack-plugin');

// include the jeet stylus plugin
var jeet = require('jeet');

// define the app directory to include in compilation
var app_directory = path.resolve(__dirname);

module.exports = {
entry: path.resolve(__dirname, 'example.styl'),
output: {
path: path.resolve(__dirname),
filename: 'example.css.js'
},
module: {
loaders: [{
// parse stylus styles
test: /\.styl$/,
// use some stylus plugins
use: [jeet()],
// extract the style into separate files
// IMPORTANT: style and css!stylus must be separated, it will not
// work otherwise
loader: ExtractTextPlugin.extract('style', 'css!stylus'),
// specify with directories to include
include: [app_directory]
}
]
},
plugins: [
// the extract-text-webpack-plugin is used to pull the css into
// a separate file
new ExtractTextPlugin('example.css'),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new webpack.optimize.OccurenceOrderPlugin()
]
};
```
The files can then be processed by running `npm run build`.


#### Browser Support

- IE9+ without help. IE8+ with Selectivizr. Obviously always use Autoprefixer.