-
-
Notifications
You must be signed in to change notification settings - Fork 294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add support for regex in cache paths #205
Changes from 4 commits
3080232
ad1b2df
4d0a950
725ae35
7e85b6c
7177c06
bcece4b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ ___________________________________ | |
Tells to the plugin what to cache and how. | ||
|
||
* `'all'`: means that everything (all the webpack output assets) and URLs listed in `externals` option will be cached on install. | ||
* `Object`: Object with 3 possible sections (properties) of type `Array<string>`: `main`, `additional`, `optional`. All sections are optional and by default are empty (no assets added). | ||
* `Object`: Object with 3 possible sections (properties) of type `Array<string|RegExp>`: `main`, `additional`, `optional`. All sections are optional and by default are empty (no assets added). | ||
|
||
> Default: `'all'`. | ||
|
||
|
@@ -43,4 +43,4 @@ AppCache doesn't support conditional or delayed assets loading and by default ig | |
AppCache: { | ||
caches: ['main', 'additional', 'optional'] | ||
} | ||
``` | ||
``` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is this change? Line break in the end? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah soz, atom's adding them automatically There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh, I see. I don't have any special feeling about trailing like breaks, I just don't like unnecessary/unrelated changes because who knows when you will need to merge things and why they could break then. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ _Also see list of default options [here](https://github.com/NekR/offline-plugin/ | |
Allows you to define what to cache and how. | ||
|
||
* `'all'`: means that everything (all the webpack output assets) and URLs listed in `externals` option will be cached on install. | ||
* `Object`: Object with 3 possible `Array<string>` sections (properties): `main`, `additional`, `optional`. All sections are optional and by default are empty (no assets added). | ||
* `Object`: Object with 3 possible `Array<string|RegExp>` sections (properties): `main`, `additional`, `optional`. All sections are optional and by default are empty (no assets added). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
[More details about `caches`](caches.md) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,14 @@ const isAbsolutePath = path.isAbsolute; | |
// Based on https://github.com/isaacs/node-glob/blob/master/glob.js#L83 | ||
// (glob.hasMagic) | ||
export function hasMagic(pattern, options) { | ||
|
||
//support RegExp as well as glob | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if (pattern instanceof RegExp) { | ||
return { | ||
match: str => pattern.test(str) | ||
}; | ||
} | ||
|
||
const minimatch = new Minimatch(pattern, options); | ||
const set = minimatch.set; | ||
|
||
|
@@ -49,4 +57,4 @@ export function isAbsoluteURL(url) { | |
return /^(?:\w+:)?\/\//.test(url); | ||
} | ||
|
||
export { isAbsolutePath } | ||
export { isAbsolutePath } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No line break in the end please here. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CACHE MANIFEST | ||
#ver:da39a3ee5e6b4b0d3255bfef95601890afd80709 | ||
|
||
CACHE: | ||
../main.js | ||
|
||
NETWORK: | ||
* |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<!doctype html> | ||
<html manifest="manifest.appcache"></html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
|
||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
|
||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) | ||
/******/ return installedModules[moduleId].exports; | ||
|
||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ exports: {}, | ||
/******/ id: moduleId, | ||
/******/ loaded: false | ||
/******/ }; | ||
|
||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
|
||
/******/ // Flag the module as loaded | ||
/******/ module.loaded = true; | ||
|
||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
|
||
|
||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
|
||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
|
||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
|
||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(0); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ([ | ||
/* 0 */ | ||
/***/ function(module, exports) { | ||
|
||
|
||
|
||
/***/ } | ||
/******/ ]); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
var __wpo = { | ||
"assets": { | ||
"main": [ | ||
"./main.js" | ||
], | ||
"additional": [], | ||
"optional": [] | ||
}, | ||
"externals": [], | ||
"hashesMap": { | ||
"fe8df8db17e5f8edb5c44ada1a7fdd9fe1a5012c": "./main.js" | ||
}, | ||
"strategy": "changed", | ||
"responseStrategy": "cache-first", | ||
"version": "da39a3ee5e6b4b0d3255bfef95601890afd80709", | ||
"name": "webpack-offline", | ||
"relativePaths": true | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = __CONFIG__({ | ||
caches: { | ||
main: [/\.js$/] | ||
}, | ||
version: 'da39a3ee5e6b4b0d3255bfef95601890afd80709' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Array<string | RegExp>