-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathwebpack.config.production.js
More file actions
92 lines (70 loc) · 1.79 KB
/
Copy pathwebpack.config.production.js
File metadata and controls
92 lines (70 loc) · 1.79 KB
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
/* eslint strict: 0 */
'use strict';
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const webpackTargetElectronRenderer = require('webpack-target-electron-renderer');
const baseConfig = require('./webpack.config.base');
const config = Object.create(baseConfig);
config.devtool = 'source-map';
config.entry = './app/app/index';
config.output.publicPath = '../dist/';
config.module.loaders.push(
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader!sass-loader')
},
{
test: /\.svg$/,
loader: 'svg-inline'
},
{
test: /\.gif$/,
loader: 'url-loader'
}
);
config.plugins.push(
new webpack.ProgressPlugin(defaultHandler),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.DefinePlugin({
'__DEV__': false,
'process.env.NODE_ENV': JSON.stringify('production')
}),
new webpack.optimize.UglifyJsPlugin({
compressor: {
screw_ie8: true,
warnings: false
}
}),
new ExtractTextPlugin('[name].css', { allChunks: true })
);
config.target = webpackTargetElectronRenderer(config);
var chars = 0, lastState, lastStateTime;
function defaultHandler(percentage, msg) {
var state = msg;
function goToLineStart(nextMessage) {
var str = '';
for(; chars > nextMessage.length; chars--) {
str += '\b \b';
}
chars = nextMessage.length;
for(var i = 0; i < chars; i++) {
str += '\b';
}
if(str) {
process.stderr.write(str);
}
}
if(percentage < 1) {
percentage = Math.floor(percentage * 100);
msg = percentage + '% ' + msg;
if(percentage < 100) {
msg = ' ' + msg;
}
if(percentage < 10) {
msg = ' ' + msg;
}
}
goToLineStart(msg);
process.stderr.write(msg);
}
module.exports = config;