added server and client production build scripts
This commit is contained in:
parent
348bedfb55
commit
9a947f7bf8
5 changed files with 48 additions and 6 deletions
|
@ -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.
|
||||
|
|
|
@ -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",
|
||||
|
|
20
webpack.prod.client.js
Normal file
20
webpack.prod.client.js
Normal file
|
@ -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),
|
||||
];
|
20
webpack.prod.server.js
Normal file
20
webpack.prod.server.js
Normal file
|
@ -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),
|
||||
];
|
|
@ -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',
|
||||
|
|
Loading…
Reference in a new issue