Last active
March 28, 2016 06:20
-
-
Save MoOx/e205fdf8b266b4ef2c92 to your computer and use it in GitHub Desktop.
Simpler webpack config concept
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`, | |
} | |
}) |
This is even better than webpack 2 syntax.
And loader order is now top to bottom :huray:
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.
My idea is to simplify so this fit in a json config :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Do you want this to be something real?