diff --git a/README.md b/README.md index 980b8179..f03e0cd5 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ Spee.ch is a web app that reads and publishes images and videos to and from the * webpack * During the build process, webpack creates two bundles for this project: * (1) a client-side app bundle which will be located at `public/bundle/bundle.js` - * (2) a server bundle which will be located at `server/index.js` + * (2) a server bundle which will be located at `index.js` * configuration * the `config/` folder contains all of the required config files. The project contains `.example` files which can be copied to create the necessary `.js` files * the `devConfig/` folder contains optional config files. Updating these files is not necessary. If you update these files, make sure to add them to your `.gitignore` file so they are not included in source control. diff --git a/package.json b/package.json index 4f865613..334a49cb 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "scripts": { "test": "mocha --recursive", "test-all": "mocha --recursive", - "start": "node server/index.js", - "start-dev": "nodemon server/index.js", + "start": "node index.js", + "start-dev": "nodemon index.js", "lint": "eslint .", "fix": "eslint . --fix", "precommit": "eslint .", @@ -15,7 +15,9 @@ "build-dev": "webpack --config webpack.dev.js", "build-dev-client": "webpack --config webpack.dev.client.js", "build-dev-server": "webpack --config webpack.dev.server.js", - "build": "webpack --config webpack.prod.js" + "build": "webpack --config webpack.prod.js", + "build-client": "webpack --config webpack.prod.client.js", + "build-server": "webpack --config webpack.prod.server.js" }, "repository": { "type": "git", diff --git a/webpack.prod.client.js b/webpack.prod.client.js new file mode 100644 index 00000000..242a19a3 --- /dev/null +++ b/webpack.prod.client.js @@ -0,0 +1,20 @@ +const webpack = require('webpack'); +const merge = require('webpack-merge'); +const UglifyJSPlugin = require('uglifyjs-webpack-plugin'); +const clientBaseConfig = require('./webpack.client.common.js'); + +const productionBuildConfig = { + devtool: 'source-map', + plugins: [ + new UglifyJSPlugin({ + sourceMap: true, + }), + new webpack.DefinePlugin({ + 'process.env.NODE_ENV': JSON.stringify('production'), + }), + ], +}; + +module.exports = [ + merge(clientBaseConfig, productionBuildConfig), +]; diff --git a/webpack.prod.server.js b/webpack.prod.server.js new file mode 100644 index 00000000..56354f85 --- /dev/null +++ b/webpack.prod.server.js @@ -0,0 +1,20 @@ +const webpack = require('webpack'); +const merge = require('webpack-merge'); +const UglifyJSPlugin = require('uglifyjs-webpack-plugin'); +const serverBaseConfig = require('./webpack.server.common.js'); + +const productionBuildConfig = { + devtool: 'source-map', + plugins: [ + new UglifyJSPlugin({ + sourceMap: true, + }), + new webpack.DefinePlugin({ + 'process.env.NODE_ENV': JSON.stringify('production'), + }), + ], +}; + +module.exports = [ + merge(serverBaseConfig, productionBuildConfig), +]; diff --git a/webpack.server.common.js b/webpack.server.common.js index c631af87..ed2c0661 100644 --- a/webpack.server.common.js +++ b/webpack.server.common.js @@ -10,8 +10,8 @@ module.exports = { externals: [nodeExternals()], entry : ['babel-polyfill', 'whatwg-fetch', './server/server.js'], output : { - path : Path.join(__dirname, 'server/'), - publicPath : 'server/', + path : Path.join(__dirname, '/'), + publicPath : '/', filename : 'index.js', library : '', libraryTarget: 'commonjs-module',