This repository was archived by the owner on Feb 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwebtasker.ts
131 lines (114 loc) · 2.67 KB
/
webtasker.ts
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
import { task, series, parallel, clone, merge, shell } from 'webtasker';
import * as webpack from 'webpack';
import * as WebpackDevServer from 'webpack-dev-server';
import * as path from 'path';
import * as HtmlWebpackPlugin from 'html-webpack-plugin';
import { TsConfigPathsPlugin, CheckerPlugin } from 'awesome-typescript-loader';
const CONFIG = {
entry: {
'index': './src/app/index'
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].js',
libraryExport: 'main',
libraryTarget: 'var',
library: 'beyond'
},
resolve: {
extensions: ['.ts', '.json', '.js']
},
target: 'web',
node: false,
module: {
strictThisContextOnImports: true,
rules: [
{
test: /\.tsx?$/,
loader: 'awesome-typescript-loader',
options: {
configFileName: 'tsconfig.webpack.json',
useCache: false
}
}
]
},
plugins: [
new CheckerPlugin(),
new TsConfigPathsPlugin({
tsconfig: path.join(__dirname, 'tsconfig.json')
}),
// new webpack.optimize.ModuleConcatenationPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new webpack.ContextReplacementPlugin(
/angular(\\|\/)core(\\|\/)@angular/,
path.join(__dirname, 'src'), // location of your src
{}
),
new HtmlWebpackPlugin({
template: 'src/app/index.html',
chunksSortMode: 'dependency',
inject: 'body'
}),
],
};
const compiler = (<any>webpack)(CONFIG);
export function build(cb) {
clean();
compiler.run(function(err, stats) {
if (err) {
console.log('Error', err);
}
console.log('[webpack]', stats.toString({
chunks: false,
colors: true
}));
cb();
});
}
watch['description'] = 'Watching build files';
export function watch() {
clean();
compiler.watch({ stdin: true }, function(err, stats) {
if (err) {
console.log('Error', err);
}
console.log('[webpack]', stats.toString({
chunks: false,
colors: true
}));
console.log('[webpack]', 'Gonna sit around and watch for file changes. CTRL^C to kill me');
});
};
export function devServer() {
clean();
const webpackServer = new WebpackDevServer(compiler, {
contentBase: path.join(__dirname, 'dist'),
compress: true,
stats: {
colors: true
},
historyApiFallback: {
rewrites: [
// { from: /^\/$/, to: '/views/landing.html' },
]
},
overlay: {
warnings: true,
errors: true
},
setup: function(app) {
}
});
webpackServer.listen(3000);
}
export function clean() {
shell.rm('-rf', 'dist');
}
export function polyfills() {
}
export default series(
clean,
polyfills,
build
);