Fix the production build configuration
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 byCleanWebpackPlugin
, 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 unusedhtml-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.