瀏覽代碼

[doc] adjust readme for file extension support

mightyplow 6 年之前
父節點
當前提交
e284095dab
共有 1 個文件被更改,包括 13 次插入8 次删除
  1. 13 8
      README.md

+ 13 - 8
README.md

@@ -15,12 +15,19 @@ npm i -D @mightyplow/inject-assets-webpack-plugin
 The assets you want to be replaced have to be wrapped in double curly braces. The assets can only
 be replaced if the target is also a webpack asset. 
 
-So for example if you want to replace the assets
-in a service worker, it has either be built by webpack or at least run through another plugin. Personally I like to
+So for example if you want to replace the assets in a service worker, it has either be built by 
+webpack or at least run through another plugin. Personally I like to
 use the [copy-webpack-plugin](https://github.com/webpack-contrib/copy-webpack-plugin) to copy the service worker 
-to the target directory.  
+to the target directory.
 
-### examples
+If there are multiple files for the same asset name, for example when you have a css file and a js file with the same
+asset name, you can specify the wanted asset by adding a pipe symbol and the file extension.
+````
+[
+    '{{vendor|js}}',
+    '{{vendor|css}}'
+]
+````
 
 Let's assume, our service worker has the following content
 
@@ -29,13 +36,11 @@ Let's assume, our service worker has the following content
 const FILES_TO_CACHE = [
     '/',
     '{{vendor}}',
-    '{{app}}'
+    '{{app|js}}'
+    '{{app|css}}'
 ]
 ````
 
-The asset names should be replaced by the output filename specified in the webpack config (or it's plugins).
-
-
 ### copied with webpack-copy-plugin
 ````
 // webpack.config.js