Skip to content

Instantly share code, notes, and snippets.

@mburakerman
Last active June 12, 2019 14:58
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mburakerman/e5e8328dc88085396adbff3804a1fb51 to your computer and use it in GitHub Desktop.
Save mburakerman/e5e8328dc88085396adbff3804a1fb51 to your computer and use it in GitHub Desktop.
Webpack 4 config.js (Stylus to CSS and Babel) πŸ‘Œ The Simplest Usage πŸ‘Œ
{
"name": "webpack-stylus",
"version": "1.0.0",
"scripts": {
"start": "webpack-dev-server --open --mode development",
"build": "webpack -p"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.4",
"babel-preset-es2015": "^6.24.1",
"css-loader": "^0.28.11",
"style-loader": "^0.20.3",
"stylus": "^0.54.5",
"stylus-loader": "^3.0.2",
"webpack": "^4.5.0",
"webpack-cli": "^2.0.14",
"webpack-dev-server": "^3.1.1"
}
}
/* === dont forget to import style to main.js file === */
/* ===> import './main.styl'; <=== */
var path = require("path");
module.exports = {
entry: "./main.js",
output: {
path: path.resolve(__dirname, "dist"),
filename: "bundle.js",
publicPath: "/dist"
},
module: {
rules: [
{
test: /\.js$/,
use: {
loader: "babel-loader",
options: { presets: ["es2015"] }
}
},
{
test: /\.styl$/,
use: [
{
loader: "style-loader" // creates style nodes from JS strings
},
{
loader: "css-loader" // translates CSS into CommonJS
},
{
loader: "stylus-loader" // compiles Stylus to CSS
}
]
}
]
}
};
@raphasp
Copy link

raphasp commented Jul 20, 2018

This is fine, but How do you do If I need to use "nib"?, thanks

@AaronPresley
Copy link

This helped me a ton, thanks!

@rudza
Copy link

rudza commented Dec 5, 2018

This is fine, but How do you do If I need to use "nib"?, thanks

https://github.com/shama/stylus-loader#using-nib-with-stylus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment