Skip to content

Instantly share code, notes, and snippets.

@mburakerman
Last active April 6, 2018 08:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mburakerman/90602a84fe6a2ed2ef164afd6163d7d5 to your computer and use it in GitHub Desktop.
Save mburakerman/90602a84fe6a2ed2ef164afd6163d7d5 to your computer and use it in GitHub Desktop.
Webpack 4 config.js (Postcss and Babel) πŸ‘Œ The Simplest Usage πŸ‘Œ
{
"name": "webpack-postcss,
"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",
"postcss-cssnext": "^3.1.0",
"postcss-loader": "^2.1.3",
"style-loader": "^0.20.3",
"webpack": "^4.5.0",
"webpack-cli": "^2.0.14",
"webpack-dev-server": "^3.1.1"
}
}
module.exports = {
plugins: {
'postcss-cssnext' : {}
}
}
/* === dont forget to import css to main.js file === */
/* ===> import './main.css'; <=== */
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: /\.css$/,
use: [
{
loader: "style-loader" // creates style nodes from JS strings
},
{
loader: "css-loader" // translates CSS into CommonJS
},
{
loader: "postcss-loader" // compiles Postcss to CSS
}
]
}
]
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment