forked from mxcube/mxcubeweb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.production.config.js
136 lines (129 loc) · 3.13 KB
/
webpack.production.config.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
var webpack = require("webpack");
var path = require('path');
var backend_server = require('./backend_server.js');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
var GitRevisionPlugin = require('git-revision-webpack-plugin');
var gitRevisionPlugin = new GitRevisionPlugin();
var CopyWebpackPlugin = require('copy-webpack-plugin')
var VIDEO_STREAM_URL = '"ws://localhost:4042/"';
try {
VIDEO_STREAM_URL = JSON.stringify(require('./config.video_url.prod.js'));
} catch (e) {
console.log("WARNING: VIDEO_STREAM_URL not set");
}
var config = {
entry: {
main: ['main.jsx'],
},
output: {
path: path.resolve(__dirname, 'mxcube3','static'),
filename: '[name]-[hash:6].js',
publicPath: ''
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules\/(?!(dygraphs)\/).*/,
use:[
"babel-loader"
]
},
{
test: /\.css$/,
use: [
{
loader: "style-loader"
},
{
loader: "css-loader",
options: {
modules: false
}
}
]
},
{
test: /\.less$/,
use: [
{
loader: "style-loader"
},
{ loader: "css-loader",
options: {
importLoaders: 1,
// modules: true,
// localsConvention: 'camelCase',
},
},
{
loader: "less-loader"
}
]
},
{
test: /\.(woff(2)?|ttf|eot|svg)(\?v=[a-z0-9]\.[a-z0-9]\.[a-z0-9])?$/,
loader: 'url-loader?limit=100000'
},
{
test: /\.(gif|png|jpe?g|svg)$/i,
loaders: [
'file-loader', {
loader: 'image-webpack-loader',
options: {
gifsicle: {
enabled: false,
interlaced: false,
},
optipng: {
enabled: false,
optimizationLevel: 7,
},
pngquant: {
enabled: false,
quality: '65-90',
speed: 4
},
mozjpeg: {
progressive: true,
quality: 65
}
}
}
]
},
{
test: /\.(ogv)$/,
use: [
{
loader: 'file-loader',
options: {}
}
]
}
]
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': '"production"'
},
'VERSION': { 'COMMITHASH': JSON.stringify(gitRevisionPlugin.commithash()),
'BRANCH': JSON.stringify(gitRevisionPlugin.branch()) },
'VIDEO_STREAM_URL': VIDEO_STREAM_URL,
'VIDEO_STREAM_ON_LOCAL_HOST': true
}),
new CopyWebpackPlugin([
{ from: 'mxcube3/ui/img/favicon.ico' },
]),
new UglifyJSPlugin()
],
externals: {
'guiConfig': JSON.stringify(require('./config.gui.prod.js')),
},
resolve: {
modules: [ path.join(__dirname, "mxcube3/ui"), "node_modules" ],
extensions: ['.js', '.jsx']
},
}
module.exports = config;