WIP - add extractor, generate snippet_data
This commit is contained in:
59
node_modules/gatsby-plugin-netlify/gatsby-node.js
generated
vendored
Normal file
59
node_modules/gatsby-plugin-netlify/gatsby-node.js
generated
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _webpackAssetsManifest = _interopRequireDefault(require("webpack-assets-manifest"));
|
||||
|
||||
var _pluginData = _interopRequireDefault(require("./plugin-data"));
|
||||
|
||||
var _buildHeadersProgram = _interopRequireDefault(require("./build-headers-program"));
|
||||
|
||||
var _createRedirects = _interopRequireDefault(require("./create-redirects"));
|
||||
|
||||
var _constants = require("./constants");
|
||||
|
||||
// https://www.netlify.com/docs/headers-and-basic-auth/
|
||||
let assetsManifest = {}; // Inject a webpack plugin to get the file manifests so we can translate all link headers
|
||||
|
||||
exports.onCreateWebpackConfig = ({
|
||||
actions,
|
||||
stage
|
||||
}) => {
|
||||
if (stage !== _constants.BUILD_HTML_STAGE && stage !== _constants.BUILD_CSS_STAGE) {
|
||||
return;
|
||||
}
|
||||
|
||||
actions.setWebpackConfig({
|
||||
plugins: [new _webpackAssetsManifest.default({
|
||||
assets: assetsManifest,
|
||||
// mutates object with entries
|
||||
merge: true
|
||||
})]
|
||||
});
|
||||
};
|
||||
|
||||
exports.onPostBuild = async ({
|
||||
store,
|
||||
pathPrefix
|
||||
}, userPluginOptions) => {
|
||||
const pluginData = (0, _pluginData.default)(store, assetsManifest, pathPrefix);
|
||||
const pluginOptions = Object.assign({}, _constants.DEFAULT_OPTIONS, userPluginOptions);
|
||||
const {
|
||||
redirects
|
||||
} = store.getState();
|
||||
let rewrites = [];
|
||||
|
||||
if (pluginOptions.generateMatchPathRewrites) {
|
||||
const {
|
||||
pages
|
||||
} = store.getState();
|
||||
rewrites = Array.from(pages.values()).filter(page => page.matchPath && page.matchPath !== page.path).map(page => {
|
||||
return {
|
||||
fromPath: page.matchPath,
|
||||
toPath: page.path
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
await Promise.all([(0, _buildHeadersProgram.default)(pluginData, pluginOptions), (0, _createRedirects.default)(pluginData, redirects, rewrites)]);
|
||||
};
|
||||
Reference in New Issue
Block a user