-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
124 lines (102 loc) · 3.16 KB
/
gulpfile.js
File metadata and controls
124 lines (102 loc) · 3.16 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
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
let gulp = require('gulp');
let ts = require('gulp-typescript');
let webpackO = require('webpack');
let webpack = require('webpack-stream');
let less = require('gulp-less');
let sourcemaps = require('gulp-sourcemaps');
let del = require('del');
const electronPackager = require('electron-packager');
let tsProject = ts.createProject('tsconfig.json');
const webpackConfig = {
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx']
},
node: {
__dirname: false
},
module: {
loaders: [
{ test: /\.tsx?$/, loader: 'awesome-typescript-loader' },
],
},
output: {
filename: 'bundle.js'
},
plugins: [
new webpackO.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
})
],
externals: {
}
};
gulp.task('copy', function() {
return gulp.src(['./package.json', './src/index.html', './src/style.less'])
.pipe(gulp.dest('./out/'));
});
gulp.task('copy-electron-search-in-page', function() {
return gulp.src([
'./node_modules/electron-in-page-search/src/*.js',
'./node_modules/electron-in-page-search/src/*.css',
'./node_modules/electron-in-page-search/src/*.html'])
.pipe(gulp.dest('./out/'));
});
gulp.task('ts', function () {
return gulp.src([
'src/**/*.ts',
'src/**/*.tsx'
])
.pipe(sourcemaps.init())
.pipe(tsProject())
.pipe(sourcemaps.write('.', { includeContent: false, sourceRoot: './' }))
.pipe(gulp.dest('./out/'));
});
gulp.task('less', function () {
return gulp.src([
'src/**/*.less'
])
.pipe(less({
paths: []
}))
.pipe(gulp.dest('./out/'));
});
gulp.task('publish', ['build-prod'], () => {
let options = {
dir: './out',
name: 'LogVisualizer',
executableName: 'logviz',
platform: 'win32',
overwrite: true
};
return electronPackager(Object.assign({
arch: 'x64'
}, options))
.then(() => {
return electronPackager(Object.assign({
arch: 'ia32'
}, options));
});
});
gulp.task('ts-webpack-main', () => {
let _webpackConfig = Object.assign({}, webpackConfig);
_webpackConfig.output.filename = 'main.js';
_webpackConfig.target = 'electron-main';
return gulp.src('./src/main.ts')
.pipe(webpack(_webpackConfig))
.pipe(gulp.dest('./out/'));
});
gulp.task('ts-webpack-renderer', ['ts-webpack-main'], () => {
let _webpackConfig = Object.assign({}, webpackConfig);
_webpackConfig.output.filename = 'renderer.js';
_webpackConfig.target = 'electron-renderer';
return gulp.src('./src/renderer.tsx')
.pipe(webpack(_webpackConfig))
.pipe(gulp.dest('./out/'));
});
gulp.task('ts-webpack', ['ts-webpack-renderer']);
gulp.task('clean', () => {
return del.sync('./out/**/*.*');
});
gulp.task('build', ['clean', 'ts', 'less', 'copy']);
gulp.task('build-prod', ['clean', 'ts-webpack', 'less', 'copy', 'copy-electron-search-in-page']);
gulp.task('default', ['build']);