@dewib/xhr-cache
Advanced tools
Comparing version 3.2.0 to 3.2.1
@@ -5,2 +5,9 @@ # Changelog | ||
### [3.2.1](https://github.com/gaetansenn/xhr-cache/compare/v3.2.0...v3.2.1) (2021-03-11) | ||
### Bug Fixes | ||
* inject plugin during build process ([1371e80](https://github.com/gaetansenn/xhr-cache/commit/1371e80580f9a36e77d26d5e988bf07f9b8822f6)) | ||
## [3.2.0](https://github.com/gaetansenn/xhr-cache/compare/v3.1.2...v3.2.0) (2021-03-11) | ||
@@ -7,0 +14,0 @@ |
@@ -210,5 +210,3 @@ import { join, resolve } from 'path' | ||
module.exports = async function xhrCache () { | ||
// Skip module during build | ||
if (this.options._build !== undefined && this.options.dev === false) { return false } | ||
// Set default path into static directory | ||
// Set default path into static directory | ||
defaultsConfig.path = join(this.nuxt.options.srcDir, defaultsConfig.rootFolder) | ||
@@ -218,2 +216,27 @@ | ||
// Inject plugin | ||
this.addPlugin({ | ||
src: resolve(__dirname, 'plugin.js'), | ||
fileName: 'xhr-cache/plugin.js', | ||
options: { | ||
config: JSON.stringify({ | ||
rootUrl: conf.rootUrl, | ||
rootFolder: conf.rootFolder, | ||
serverUrl: conf.serverUrl | ||
}), | ||
resources: JSON.stringify(resources.map(resource => ({ | ||
id: resource.id | ||
}))) | ||
} | ||
}) | ||
// Extend xhrCache with plugins | ||
if (conf.plugins) { | ||
conf.plugins.forEach(p => this.options.plugins.push(p)) | ||
delete conf.plugins | ||
} | ||
// Skip server middleware injection during build | ||
if (this.options._build !== undefined && this.options.dev === false) { return false } | ||
conf.serverUrl = `http${this.options.server.https ? 's' : ''}://${this.options.server.host}:${this.options.server.port}` | ||
@@ -335,24 +358,2 @@ | ||
}) | ||
// Inject plugin | ||
this.addPlugin({ | ||
src: resolve(__dirname, 'plugin.js'), | ||
fileName: 'xhr-cache/plugin.js', | ||
options: { | ||
config: JSON.stringify({ | ||
rootUrl: conf.rootUrl, | ||
rootFolder: conf.rootFolder, | ||
serverUrl: conf.serverUrl | ||
}), | ||
resources: JSON.stringify(resources.map(resource => ({ | ||
id: resource.id | ||
}))) | ||
} | ||
}) | ||
// Extend xhrCache with plugins | ||
if (conf.plugins) { | ||
conf.plugins.forEach(p => this.options.plugins.push(p)) | ||
delete conf.plugins | ||
} | ||
} |
{ | ||
"name": "@dewib/xhr-cache", | ||
"version": "3.2.0", | ||
"version": "3.2.1", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "Cache api resources and serve it as static resource", |
@@ -1,2 +0,2 @@ | ||
# XHR Cache Module v3.2.0 | ||
# XHR Cache Module v3.2.1 | ||
@@ -3,0 +3,0 @@ [![npm version][npm-version-src]][npm-version-href] |
23963