-
Notifications
You must be signed in to change notification settings - Fork 126
/
webpack.stg.js
69 lines (65 loc) · 2.21 KB
/
webpack.stg.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
const path = require('path');
const webpack = require('webpack');
const getCommon = require('./webpack.common.js');
const merge = require('webpack-merge');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
process.env.NODE_ENV = 'production';
const appName=process.env.APP;
console.log(`Building ${appName}...`);
const favicon = process.env.DOMAIN || 'missions';
const title = (domain => {
switch (domain) {
default:
case 'missions':
return 'Missions';
case 'mooving':
return 'Mooving';
}
})(process.env.DOMAIN);
module.exports = merge(getCommon(process.env.NODE_ENV,appName), {
devtool: 'cheap-module-source-map',
devServer: {
inline: true,
contentBase: path.resolve(__dirname, 'src'),
host:'0.0.0.0',
port: 3333,
historyApiFallback: true,
},
plugins: [
new CleanWebpackPlugin([`dist/${appName}`]),
new webpack.DefinePlugin({
'process.env': {
APP: JSON.stringify(process.env.APP),
DOMAIN: JSON.stringify(process.env.DOMAIN),
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
BLOCKCHAIN_TYPE: JSON.stringify('MAINNET'),
MISSION_CONTROL_URL: JSON.stringify('https://ctrl.mooving.io'),
CAPTAIN_SIM_URL: JSON.stringify('https://captain-sim.mooving.io'),
},
}),
new CopyWebpackPlugin([
{ from: path.resolve(__dirname, `src/favicon_${favicon}.ico`), to: path.resolve(__dirname, `src/favicon.ico`) }
]),
new HtmlWebpackPlugin({
filename: 'index.html',
chunks: ['vendor', 'app'],
title:`${title}`,
template: path.resolve(__dirname, 'src/index.html'),
favicon: path.resolve(__dirname, 'src/favicon.ico'),
}),
new CopyWebpackPlugin([
{ from: 'src/images', to: 'images' },
{ from: 'src/browserconfig.xml' },
{ from: 'src/manifest.json' },
{ from: 'src/lib/mapbox-gl-rtl-text.js.min' , to: 'lib' },
]),
new ExtractTextPlugin('[name].bundle.css'),
new UglifyJSPlugin({
sourceMap: true,
}),
],
});