Open blazeu opened 6 years ago
uhh, can I see your gatsby-config
file?
const autoprefixer = require('autoprefixer')
module.exports = {
plugins: [
`gatsby-plugin-react-next`,
`gatsby-plugin-react-helmet`,
{
resolve: `gatsby-plugin-postcss-sass`,
options: {
postCssPlugins: [
autoprefixer({
browsers: ['last 2 versions'],
}),
],
precision: 8,
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: `content`,
path: `${__dirname}/content/`,
},
},
`gatsby-transformer-yaml`,
`gatsby-transformer-sharp`,
`gatsby-plugin-sharp`,
`gatsby-plugin-purify-css`,
],
}
There you go, I guess it's gatsby-plugin-postcss-sass
that's problematic.
@blazeu will take a look this weekend, in the meantime, try putting putting the gatsby-plugin-postcss-sass
entry after gatsby-plugin-purfiy-css
in the plugins array.
That did the trick, thanks!
Reopening because this probably needs some inspection on why it breaks.
i've got the same, putting it all the way up (above all style, css-in-js e.g. glamor related stuff) solved it
@blazeu, @CanRau are your repositories open source? would be helpful in debugging this.
it's going to be but still under heavy development so I haven't even "played" with your module I just threw it in for later ;-)
No problem!
I you haven't figured it out by then I'll let you know ;)
You can replicate this issue by updating the example application in this repository to use gatsby: "next"
Haven't had a change to dive too deeply into the issue, but it appears that some functions that aren't supported are being exported by webpack.
Logging out pluginAPIKeys
and apis
before this line results in:
pluginAPIKeys = [ undefined,
'writeFile',
'readFile',
'readFile',
'writeFile',
'onPostBuild',
'default',
'default',
'default' ]
apis =[ 'resolvableExtensions',
'createPages',
'createPagesStatefully',
'sourceNodes',
'onCreateNode',
'onCreatePage',
'setFieldsOnGraphQLNodeType',
'preprocessSource',
'generateSideEffects',
'onCreateBabelConfig',
'onCreateWebpackConfig',
'onPreInit',
'onPreBootstrap',
'onPostBootstrap',
'onPreBuild',
'onPostBuild',
'onPreExtractQueries' ]
Given that there are 3 default
keys in there, I suspect that would be the result from using export default...
The undefined
is what causes the specific issue mentioned by the way.
Good catch 👍
Fix might be as simple as converting to commonjs style imports / exports in the source or tweaking the webpack config. Will give that a shot and see if it closes out the issue.
@youfoundron Any joy with this? I've tried to see if I can make any progress, but I don't know enough about webpack / babel to make any real progress.
With a little hacking, I was able to get some more useful output as to the error:
error
Your plugins must export known APIs from their gatsby-node.js.
The following exports aren't APIs. Perhaps you made a typo or your plugin is outdated?
See https://www.gatsbyjs.org/docs/node-apis/ for the list of Gatsby Node APIs
- The plugin "gatsby-plugin-purify-css@2.2.1" is exporting a variable named "undefined" which isn't an API.
- The plugin "gatsby-plugin-purify-css@2.2.1" is exporting a variable named "writeFile" which isn't an API.
- The plugin "gatsby-plugin-purify-css@2.2.1" is exporting a variable named "readFile" which isn't an API.
- The plugin "gatsby-plugin-purify-css@2.2.1" is exporting a variable named "readFile" which isn't an API.
- The plugin "gatsby-plugin-purify-css@2.2.1" is exporting a variable named "writeFile" which isn't an API.
- The plugin "gatsby-plugin-purify-css@2.2.1" is exporting a variable named "default" which isn't an API.
- The plugin "gatsby-plugin-purify-css@2.2.1" is exporting a variable named "default" which isn't an API.
- The plugin "gatsby-plugin-purify-css@2.2.1" is exporting a variable named "default" which isn't an API.
For anyone else who finds this issue and wants to try and get this running today, the following is currently working for me.
node_modules/gatsby/dist/bootstrap/load-plugins/index.js
and removing or commenting out lines 69-72yarn
)src/index.js
to add import 'babel-polyfill'
as the first lineyarn build
gatsby-node.js
file from this repo to node_modules/gatsby-plugin-purify-css/
in your Gatsby appgatsby build
againWith these hacks I was able to get it running, but in the end I got the following output:
________________________________________________
|
| PurifyCSS has reduced the file size by ~ 0.0%
|
________________________________________________
throws error when building and then exits.
Using gatsby v1.9.214