Skip to content

Commit e01bb38

Browse files
committed
uglify the output js, and udpate webpack to 3
1 parent 1fd69b3 commit e01bb38

File tree

5 files changed

+60
-35
lines changed

5 files changed

+60
-35
lines changed

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"qrcode-npm": "0.0.3",
3838
"request": "^2.74.0",
3939
"stream-throttle": "^0.1.3",
40+
"svg-inline-react": "^1.0.2",
4041
"whatwg-fetch": "^1.0.0",
4142
"ws": "^2.2.0"
4243
},
@@ -60,7 +61,7 @@
6061
"eslint-plugin-import": "^2.7.0",
6162
"eslint-plugin-jsx-a11y": "^5.1.1",
6263
"eslint-plugin-react": "^7.4.0",
63-
"extract-text-webpack-plugin": "^1.0.1",
64+
"extract-text-webpack-plugin": "^3.0.2",
6465
"file-loader": "^0.9.0",
6566
"https-proxy-agent": "^1.0.0",
6667
"jasmine": "^2.5.3",
@@ -88,9 +89,8 @@
8889
"stream-equal": "0.1.8",
8990
"style-loader": "^0.13.1",
9091
"svg-inline-loader": "^0.7.1",
91-
"svg-inline-react": "^1.0.2",
9292
"url-loader": "^0.5.7",
93-
"webpack": "^1.12.9",
93+
"webpack": "^3.10.0",
9494
"worker-loader": "^0.7.1"
9595
},
9696
"scripts": {
@@ -99,8 +99,8 @@
9999
"lint": "eslint .",
100100
"testserver": "node test/server/startServer.js",
101101
"testOutWeb": "jasmine test/spec_outweb/test_realweb_spec.js",
102-
"buildweb": "NODE_ENV=production webpack --config web/webpack.config.js --process --colors",
103-
"webserver": "NODE_ENV=test webpack --config web/webpack.config.js --process --colors --watch",
102+
"buildweb": "NODE_ENV=production webpack --config web/webpack.config.js --colors",
103+
"webserver": "NODE_ENV=test webpack --config web/webpack.config.js --colors --watch",
104104
"doc:serve": "node build_scripts/prebuild-doc.js && gitbook serve ./docs-src ./docs --log debug",
105105
"doc:build": "./build_scripts/build-doc-site.sh"
106106
},

web/postcss.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
plugins: [
3+
require('autoprefixer')
4+
]
5+
}

web/src/component/header-menu.jsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ class HeaderMenu extends React.Component {
208208
onClick={this.stopRecording}
209209
>
210210
<div className={Style.filterIcon}>
211-
<InlineSVG src={require('svg-inline!assets/stop.svg')} />
211+
<InlineSVG src={require('svg-inline-loader!assets/stop.svg')} />
212212
</div>
213213
<span>Stop</span>
214214
</a>
@@ -221,7 +221,7 @@ class HeaderMenu extends React.Component {
221221
onClick={this.resumeRecording}
222222
>
223223
<div className={Style.stopIcon}>
224-
<InlineSVG src={require('svg-inline!assets/play.svg')} />
224+
<InlineSVG src={require('svg-inline-loader!assets/play.svg')} />
225225
</div>
226226
<span>Resume</span>
227227
</a>
@@ -234,7 +234,7 @@ class HeaderMenu extends React.Component {
234234
onClick={this.showFilter}
235235
>
236236
<div className={Style.stopIcon}>
237-
<InlineSVG src={require('svg-inline!assets/filter.svg')} />
237+
<InlineSVG src={require('svg-inline-loader!assets/filter.svg')} />
238238
</div>
239239
<span>Filter</span>
240240
</a>
@@ -250,7 +250,7 @@ class HeaderMenu extends React.Component {
250250
onClick={this.clearAllRecord}
251251
title="Ctrl + X"
252252
>
253-
<InlineSVG src={require('svg-inline!assets/clear.svg')} />
253+
<InlineSVG src={require('svg-inline-loader!assets/clear.svg')} />
254254
<span>Clear</span>
255255
</a>
256256
{inAppMode ? filterMenu : null}
@@ -269,7 +269,7 @@ class HeaderMenu extends React.Component {
269269
href="javascript:void(0)"
270270
>
271271
<div className={Style.tipIcon} >
272-
<InlineSVG src={require('svg-inline!assets/tip.svg')} />
272+
<InlineSVG src={require('svg-inline-loader!assets/tip.svg')} />
273273
</div>
274274
<span>Proxy Info</span>
275275
</a>

web/src/component/left-menu.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class LeftMenu extends React.Component {
9393
title="Only show the filtered result"
9494
>
9595
<span className={Style.filterIcon}>
96-
<InlineSVG src={require('svg-inline!assets/filter.svg')} />
96+
<InlineSVG src={require('svg-inline-loader!assets/filter.svg')} />
9797
</span>
9898
<span>Filter</span>
9999
</a>
@@ -105,7 +105,7 @@ class LeftMenu extends React.Component {
105105
title="Download the root CA to the computer and your phone"
106106
>
107107
<span className={Style.downloadIcon}>
108-
<InlineSVG src={require('svg-inline!assets/download.svg')} />
108+
<InlineSVG src={require('svg-inline-loader!assets/download.svg')} />
109109
</span>
110110
<span>RootCA</span>
111111
</a>

web/webpack.config.js

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ const path = require('path');
33
const autoprefixer = require('autoprefixer');
44
const ExtractTextPlugin = require('extract-text-webpack-plugin');
55

6+
const UglifyJsPlugin = webpack.optimize.UglifyJsPlugin;
7+
68
const extractCss = new ExtractTextPlugin('[name].css', {
79
disable: false,
810
allChunks: true
@@ -22,73 +24,91 @@ module.exports = {
2224
filename: 'main.js'
2325
},
2426
resolve: {
25-
root: path.join(__dirname, 'src'),
26-
extensions: ['', '.js', '.jsx']
27+
modules: [
28+
'node_modules',
29+
path.join(__dirname, 'src')
30+
],
31+
extensions: ['.', '.js', '.jsx']
2732
},
2833
module: {
29-
loaders: [{
34+
rules: [{
3035
test: /\.js$/,
3136
exclude: /node_modules/,
32-
loader: 'babel',
33-
query: {
37+
loader: 'babel-loader',
38+
options: {
3439
presets: ['es2015', 'stage-0']
3540
}
3641
},
3742
{
3843
test: /\.jsx$/,
3944
exclude: /node_modules/,
40-
loader: 'babel',
41-
query: {
42-
presets: ['es2015', 'stage-0', 'react'],
43-
plugins: ['transform-runtime', ['import', { libraryName: 'antd', style: true }]]
45+
use: {
46+
loader: 'babel-loader',
47+
options: {
48+
presets: ['es2015', 'stage-0', 'react'],
49+
plugins: [['import', { libraryName: 'antd', style: true }]]
50+
}
4451
}
4552
},
4653
{
4754
test: function (filePath) {
4855
return (/antd\/.*\.less$/.test(filePath) || /\.global\.less$/.test(filePath));
4956
},
50-
loader: ExtractTextPlugin.extract('css!postcss!less')
57+
use: ExtractTextPlugin.extract({use: 'css-loader!postcss-loader!less-loader'})
5158
},
5259
{
5360
test: function (filePath) {
5461
return (/\.less$/.test(filePath) && !/\.global\.less$/.test(filePath) && !/antd\/.*\.less$/.test(filePath));
5562
},
56-
loader: ExtractTextPlugin.extract('css?modules&localIdentName=[local]___[hash:base64:5]!postcss!less')
63+
use: ExtractTextPlugin.extract({use: 'css-loader?modules&localIdentName=[local]___[hash:base64:5]!postcss-loader!less-loader'})
5764
},
5865
{
5966
test: /\.css$/,
60-
loader: ExtractTextPlugin.extract('css')
67+
use: ExtractTextPlugin.extract({use:'css-loader'})
6168
},
6269
{
6370
test: /\.png(\?v=\d+\.\d+\.\d+)?$/,
64-
loader: 'url?limit=10000&mimetype=image/png'
71+
use: {
72+
loader: 'url-loader?limit=10000&mimetype=image/png'
73+
}
6574
},
6675
{
6776
test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
68-
loader: 'url?limit=10000&mimetype=application/font-woff'
77+
use: {
78+
loader: 'url-loader?limit=10000&mimetype=application/font-woff'
79+
}
6980
},
7081
{
7182
test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
72-
loader: 'url?limit=10000&mimetype=application/font-woff'
83+
use: {
84+
loader: 'url-loader?limit=10000&mimetype=application/font-woff'
85+
}
7386
},
7487
{
7588
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
76-
loader: 'url?limit=10000&mimetype=application/octet-stream'
89+
use: {
90+
loader: 'url-loader?limit=10000&mimetype=application/octet-stream'
91+
}
7792
},
7893
{
7994
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
80-
loader: 'url?limit=10000&mimetype=application/octet-stream'
95+
use: {
96+
loader: 'url-loader?limit=10000&mimetype=application/octet-stream'
97+
}
8198
},
8299
{
83100
test: /font\.svg(\?v=\d+\.\d+\.\d+)?$/,
84-
loader: 'url?limit=10000&mimetype=image/svg+xml'
101+
use: {
102+
loader: 'url-loader?limit=10000&mimetype=image/svg+xml'
103+
}
85104
}]
86105
},
87-
postcss: function () {
88-
return [autoprefixer];
89-
},
90106
plugins: [
91107
extractCss,
92-
defineProperty
93-
]
108+
defineProperty,
109+
new UglifyJsPlugin()
110+
],
111+
stats: {
112+
children: false
113+
}
94114
};

0 commit comments

Comments
 (0)