DavidWells / PostCSS-tutorial

Tutorial on adding PostCSS to `create-react-app` CLI
102 stars 14 forks source link

unstyled production build #29

Open headwinds opened 7 years ago

headwinds commented 7 years ago

great tutorial! everything worked in development until I tried to build and deploy it...

I'm not using a nodejs server in production and want to build the app the create-react-app way and deploy it to an apache server:

npm run build

In the terminal, I'm prompted to test the build

Successfully generated a bundle in the build folder!

You can now serve it with any static server, for example:
  cd build
  npm install -g http-server
  hs
  open http://localhost:8080

When I open the browser, I see the app but it's completely unstyled. Any thoughts? If you build this project locally using npm run build, do you also see an unstyled app?

headwinds commented 7 years ago

I got it to work by using the dev configuration in production!

postCSS-tutorial build with dev config

In build.js I simply changed:

process.env.NODE_ENV = 'production';

var path = require('path');
var rimrafSync = require('rimraf').sync;
var webpack = require('webpack');
var config = require('../config/webpack.config.dev');

So there seems to be something off in the production config if you want this to work on something other than a nodejs server... for now, I'll go with the dev config unless there is a major reason why this is a bad idea beside being a dev config but it does solve my immediate need.