Enabling assets for Server-Side Rendering in Webpack (file-loader, url-loader, css-loader/locals)

medium.com

file-loader and url-loader support not-emitting-files themselves now, so fake-file-loader and fake-url-loader are deprecated. fake-style-loader can be replaced by using css-loader/locals as explained in fake-style-loader#3. So, do not use the fake module family anymore. It is recommended to use css-loader, file-loader and url-loader directly instead.

もともとのfakeシリーズの狙い

  • Client, Serverで2回ビルドを走らせると、Webpack would emit the files twice, possibly resulting in different URLs という問題がある。
  • じゃあ、そもそも成果物をemit(生成)しなければいいじゃないか。という発想。
  • fake-style-loader に関しては、heading sourceという2つの情報を含んだオブジェクトを吐き出すので、必要なら自分で其の結果を利用してSSRしてね、みたいなスタンス

css/localsをサーバ側のビルド設定で用いる

github.com