@gasket/plugin-nextjs
Version:
Adds Next support to your application
45 lines (44 loc) • 1.32 kB
JavaScript
/// <reference types="@gasket/plugin-workbox" />
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, /**
* Workbox config partial to add Next.js static assets to precache
* @type {import('@gasket/core').HookHandler<'workbox'>}
*/ "default", {
enumerable: true,
get: function() {
return workbox;
}
});
const _url = /*#__PURE__*/ _interop_require_default(require("url"));
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
function _interop_require_default(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
const isDefined = (o)=>typeof o !== 'undefined';
function workbox(gasket) {
const { nextConfig = {}, basePath: rootBasePath } = gasket.config;
const assetPrefix = [
nextConfig.assetPrefix,
nextConfig.basePath,
rootBasePath,
''
].find(isDefined);
const parsed = assetPrefix ? _url.default.parse(assetPrefix) : '';
const joined = parsed ? _url.default.format({
...parsed,
pathname: _path.default.join(parsed.pathname, '_next/')
}) : '_next/';
return {
globDirectory: '.',
globPatterns: [
'.next/static/**'
],
modifyURLPrefix: {
'.next/': joined
}
};
}