Skip to content

Fix the production build configuration

Alf Eaton requested to merge production-build into master

The production build process hadn't been used before, so this adds a few changes to get the build process functional:

  • Add CleanWebpackPlugin to remove the _build/assets folder before building.
  • Write the client config JSON file to _build/config so that it doesn't get removed by CleanWebpackPlugin, which runs after the client config file is written.
  • Use an HTML + lodash index template with HtmlWebpackPlugin (the default), remove the old .ejs template and the unused html-loader.
  • Add UglifyJSPlugin to minify the JS output.
  • Finish enabling ExtractTextPlugin to extract CSS to a separate file (only for the production build, as it interferes with hot module reloading).

NODE_ENV=production npm run start now works as expected, where pubsweet-server serves the static files.

NODE_ENV=production npm run build generates the output files, but pubsweet-server needs to have CORS headers added to the API before they can be deployed independently.

Edited by Alf Eaton

Merge request reports