create-static-site
create-static-site copied to clipboard
Add support for common loader types in webpack config
Right now the webpack config is only processing JS.
What if I want to:
- require images/files/etc?
- should we use url-loader to transform small URL/file endpoints into their base64 equivalents?
- require JSON? => ([email protected]) should handle this
- require CSS? => don't output it, just make it importable using PostCSS?
- require markdown?
Calling all static site power rangers @ncphillips @zivbk1 @budparr @scottgallant
- Requiring json is default since webpack 2.
- Some third party dependencies export css, so even if we don’t encourage importing css as the way of using your own, it might make sense for people.
- requiring markdown is just loading text files. I’m not sure if loaders exist for loading front matter files, but my gut says we should put that off until we know people want that feature. Maybe make a feature request issue and wait until it gets a bunch of thumbs up
Let’s take a look at create React apps approach for some inspiration.
Maybe this should be another issue of discussion, but also note that they separate dev and prod webpack configs. I think this is the right approach. Duplication is easier to deal with then the insanity of maintaining one file that does both.
I went through CRA's webpack configs and honestly, a lot of it made a lot of sense.
Pulled anything that wasn't specific to React and then customized it to a static build versus a React app.
It's so nicely commented.
Are you including the config to allow for JSX syntax @chrisdmacrae ?
@ncphillips Sure am! https://github.com/forestryio/create-static-site/blob/remove-gulp/packages/static-scripts/config/webpack.config.dev.js