Skip to content

Instantly share code, notes, and snippets.

@MoOx
Last active March 28, 2016 06:20
Show Gist options
  • Save MoOx/e205fdf8b266b4ef2c92 to your computer and use it in GitHub Desktop.
Save MoOx/e205fdf8b266b4ef2c92 to your computer and use it in GitHub Desktop.
Simpler webpack config concept
import webpackSimpleConfig from "webpack-simple-config"
/*
ideas:
- simpler config
- fix loaders order (imo, more logical order): proof is that every new webpack user don't get this part
- no tons of way to provide config via string, query etc
- some shortcuts: simple extract, aliases
*/
export default webpackSimpleConfig({
loaders: {
css: {
"postcss-loader": true,
"css-loader": {
modules: true,
localIdentName: "[path][name]--[local]--[hash:base64:5]",
},
"style-loader": true,
},
"html|ico|jpe?g|png|gif": {
"file-loader": {
name: "[path][name].[ext]",
context: path.join(config.cwd, config.source),
}
},
"svg": [ "svgo-loader", "raw-loader" ],
"woff2|woff|ttf|eot": "file-loader",
}
extract: [ "css" ],
aliases: {
"~": `${__dirname}/src`,
}
})
@MoOx
Copy link
Author

MoOx commented Mar 17, 2016

Do you want this to be something real?

@thangngoc89
Copy link

This is even better than webpack 2 syntax.

And loader order is now top to bottom :huray:

@istarkov
Copy link

IMHO current webpack loaders order more intuitive,
just think about loaders as about functions combined with compose operation.

compose (
  style-loader,
  css-loader,
  postcss-loader
)

You get the idea.

@MoOx
Copy link
Author

MoOx commented Mar 18, 2016

My idea is to simplify so this fit in a json config :)

@MoOx
Copy link
Author

MoOx commented Mar 28, 2016

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