Browse Source

[doc] adjust readme for file extension support

mightyplow 6 years ago
parent
commit
e284095dab
1 changed files with 13 additions and 8 deletions
  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
 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. 
 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 
 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
 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 = [
 const FILES_TO_CACHE = [
     '/',
     '/',
     '{{vendor}}',
     '{{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
 ### copied with webpack-copy-plugin
 ````
 ````
 // webpack.config.js
 // webpack.config.js