React webpack 部署
React webpack 部署
"build": "NODE_ENV=production API_HOST=http://rdpc.git4u.net:2650/ babel-node client/startProd.js",import path from 'path';
import webpack from 'webpack';
import _debug from 'debug';
const debug = _debug('Redux-Bolierplate:Build');
debug('Start Build Source...');
webpack({
devtool: false,
entry: [
'babel-polyfill',
path.join(__dirname, 'entry.js'),
],
output: {
path: path.join(__dirname, 'build'),
filename: 'bundle.js',
publicPath: '/build/',
},
plugins: [
new webpack.DefinePlugin({
API_HOST: `"${process.env.API_HOST || '/api'}"`,
API_VERSION: `"${process.env.API_VERSION || '0.0.0'}"`,
'process.env.NODE_ENV': '"production"',
}),
new webpack.optimize.UglifyJsPlugin(),
new webpack.optimize.DedupePlugin(),
new webpack.NoErrorsPlugin(),
],
module: {
loaders: [{
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/,
include: __dirname,
}, {
test: /\.(jpe?g|png|gif|svg)$/i,
loaders: [
'file?hash=sha512&digest=hex&name=[hash].[ext]',
'image-webpack?bypassOnDebug&optimizationLevel=7&interlaced=false',
],
exclude: /node_modules/,
}, {
test: /\.css$/,
loader: 'style-loader!css-loader'
}],
},
}, (err) => {
if (err) {
debug(err);
} else {
console.log('Build Successful!');
debug('Build Successful!');
}
});之後開始設定nginx環境
#Server render 的部署
#如果使用pm2更新server檔案後要記得restart
使用Create-react-app 部署
Last updated