create-static-site icon indicating copy to clipboard operation
create-static-site copied to clipboard

Add support for common loader types in webpack config

Open chrisdmacrae opened this issue 6 years ago • 5 comments

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

chrisdmacrae avatar Feb 27 '18 03:02 chrisdmacrae

  • 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.

ncphillips avatar Feb 27 '18 11:02 ncphillips

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.

chrisdmacrae avatar Feb 28 '18 14:02 chrisdmacrae

It's so nicely commented.

budparr avatar Feb 28 '18 14:02 budparr

Are you including the config to allow for JSX syntax @chrisdmacrae ?

ncphillips avatar Feb 28 '18 18:02 ncphillips

@ncphillips Sure am! https://github.com/forestryio/create-static-site/blob/remove-gulp/packages/static-scripts/config/webpack.config.dev.js

chrisdmacrae avatar Mar 01 '18 00:03 chrisdmacrae