Процесс создания в моем блог-проекте занимает очень много времени. После очистки каталогов / publi c и /. Cache сборка завершается после ~ 300 se c.
Я пытался уменьшить вес отдельных каталогов с содержимым блога. Я удалил все изображения (общий вес от 28 МБ до 17,2 МБ), но это не решило проблему.
В процессе этого процесса я получаю следующую ошибку несколько раз:
[BABEL] Note: The code generator has deoptimised the styling of undefined as it exceeds the max of 500KB.
Чтобы устранить эту ошибку, я попытался использовать дополнительный конфигурационный файл Babel {"env": { "development" : { "compact": false }}}
с помощью плагина babel-preset-gatsby , но он не работал.
Буду признателен за вашу помощь. Спасибо!
плагины в gatsby-config. js
plugins: [
"gatsby-plugin-sharp",
"gatsby-transformer-sharp",
{
resolve: "gatsby-plugin-mdx",
options: {
plugins: ["gatsby-remark-images"],
gatsbyRemarkPlugins: [
{
resolve: "gatsby-remark-copy-linked-files"
},
{
resolve: "gatsby-remark-images",
options: {
maxWidth: 800
}
},
{
resolve: "gatsby-remark-autolink-headers",
options: { icon: false }
},
{
resolve: "gatsby-remark-prismjs",
options: {
classPrefix: "language-",
aliases: {},
showLineNumbers: false,
noInlineHighlight: false
}
}
]
}
},
"gatsby-plugin-react-helmet",
{
resolve: "gatsby-plugin-nprogress",
options: {
color: "rgb(67, 132, 245)",
showSpinner: false
}
},
"gatsby-transformer-json",
{
resolve: "gatsby-source-filesystem",
options: {
name: "pages",
path: `${__dirname}/content`
}
},
{
resolve: "gatsby-plugin-manifest",
options: {
name: "gatsby-default-mdx-basic",
short_name: "starter",
start_url: "/",
background_color: "#663399",
theme_color: "#663399",
display: "minimal-ui"
}
},
{
resolve: "gatsby-plugin-google-fonts",
options: {
fonts: ["source sans pro\:400,500,600,700"],
display: "swap"
}
},
"gatsby-plugin-sitemap"
]
gatsby- node.js
const path = require("path");
const { createFilePath } = require("gatsby-source-filesystem");
exports.onCreateWebpackConfig = ({ actions }) => {
actions.setWebpackConfig({
resolve: {
modules: [
path.resolve(__dirname, "src"),
path.resolve(__dirname, "content"),
"node_modules"
],
alias: {
react: require.resolve("react"),
"react-dom": require.resolve("react-dom")
}
}
});
};
exports.onCreateNode = ({ node, actions, getNode }) => {
const { createNodeField } = actions;
if (node.internal.type === "Mdx") {
const value = createFilePath({ node, getNode });
createNodeField({
name: "slug",
node,
value
});
}
};
exports.createPages = async ({ graphql, actions, reporter }) => {
const { createPage } = actions;
const result = await graphql(`
query {
allMdx {
edges {
node {
id
fields {
slug
}
frontmatter {
slug
}
parent {
... on File {
modifiedTime(formatString: "MM/DD/YYYY")
}
}
}
}
}
}
`);
if (result.errors) {
reporter.panicOnBuild('? ERROR: Loading "createPages" query');
}
const pages = result.data.allMdx.edges;
pages.forEach(({ node }, index) => {
createPage({
path: node.frontmatter.slug || node.fields.slug,
component: path.resolve("./src/templates/page.js"),
context: { id: node.id, modifiedTime: node.parent.modifiedTime }
});
});
};