Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set NODE_ENV=production on node process when running "gatsby build" #337

Closed
emilyaviva opened this issue Jun 17, 2016 · 8 comments
Closed

Comments

@emilyaviva
Copy link
Contributor

emilyaviva commented Jun 17, 2016

I am finishing a Gatsby-ified version of my personal website (http://emilyaviva.github.io/eakm-website-gatsby) and a sticking point seems to be that when the source (http://github.com/emilyaviva/eakm-website-gatsby) is run normally in develop mode, the font-awesome fonts get included, but when it is actually built, the font-awesome fonts don't make it in, somehow. My guess is this has to do with the Webpack loader config, but I'm not sure how. Any ideas?

@emilyaviva emilyaviva changed the title Using Using font-awesome Jun 17, 2016
@KyleAMathews
Copy link
Contributor

TBH, I haven't tried loading fonts with Gatsby. Someone else contributed the font webpack config here

// Font loaders
config.loader('woff', {
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url-loader?limit=10000&minetype=application/font-woff',

It is setup to run the same though in both develop and production.

@emilyaviva
Copy link
Contributor Author

It worked fine once I built it with NODE_ENV=production. All I've done, in my index.js, is import 'font-awesome/scss/font-awesome.scss', which uses the built-in Sass loader. I haven't needed to mess with custom loaders for woff, ttf, etc. files.

I like it when things Just Work™! :)

@KyleAMathews
Copy link
Contributor

Mmmm... I've heard people say this before and it just occurred to me why. We autoset NODE_ENV=production on gatsby build in the Webpack build but that only applies to inside Webpack e.g. the React.js code and not to stuff outside of the Webpack context e.g. Webpack loaders. I don't have time to throughly investigate this right now but I'm guessing that's the problem and the solution would be to set process.env.NODE_ENV = 'production' on startup when running gatsby build. I'm going to re-open this issue and change the title.

@KyleAMathews KyleAMathews reopened this Jun 18, 2016
@KyleAMathews KyleAMathews changed the title Using font-awesome Set NODE_ENV=production on node process when running "gatsby build" Jun 18, 2016
KyleAMathews added a commit that referenced this issue Jul 6, 2016
Fixes #337

There seems to be a few Webpack loaders that require this e.g.
sass-loader. We set NODE_ENV to production already *inside* Webpack e.g.
for React's optimizations but this PR is necessary for code *outside*
Webpack e.g. node code in Webpack loaders.
KyleAMathews added a commit that referenced this issue Jul 6, 2016
Fixes #337

There seems to be a few Webpack loaders that require this e.g.
sass-loader. We set NODE_ENV to production already *inside* Webpack e.g.
for React's optimizations but this PR is necessary for code *outside*
Webpack e.g. node code in Webpack loaders.
@KyleAMathews
Copy link
Contributor

@emilyaviva this is going out in a new release in a sec. Would be very appreciative if you could upgrade and see if the issue is in fact resolved.

@ivanoats
Copy link
Contributor

ivanoats commented Jul 6, 2016

I think this does it! Thanks Kyle, you have been rockin' today 🚀

@KyleAMathews
Copy link
Contributor

:D thanks!
On Tue, Jul 5, 2016 at 8:37 PM Ivan Storck notifications@github.com wrote:

I think this does it! Thanks Kyle, you have been rockin' today 🚀


You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
#337 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAEVh9TAPu5KZDfAzjaXy_NLNVEVXmP9ks5qSyMLgaJpZM4I4t0k
.

@emilyaviva
Copy link
Contributor Author

fixz0r3d!

@KyleAMathews
Copy link
Contributor

💯
On Tue, Jul 5, 2016 at 9:58 PM Emily Aviva Kapor-Mater <
notifications@github.com> wrote:

fixz0r3d!


You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
#337 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAEVh8WyFvGoWANoS9Td2w3ioUxBYdtoks5qSzYBgaJpZM4I4t0k
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants