-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
82 lines (63 loc) · 2.43 KB
/
gulpfile.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
'use strict';
const gulp = require('gulp');
const build = require('@microsoft/sp-build-web');
build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`);
build.addSuppression(/filename should end with module/);
// Merge custom loader to web pack configuration
const VueLoaderPlugin = require('vue-loader/lib/plugin');
const vuePlugin = new VueLoaderPlugin();
const themedStyleLoader = require.resolve('@microsoft/loader-load-themed-styles');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const forkTsPlugin = new ForkTsCheckerWebpackPlugin({
vue: true,
tslint: true,
formatter: 'codeframe',
checkSyntacticErrors: false,
watch: '/src/**/*.vue'
});
build.configureWebpack.mergeConfig({
additionalConfiguration: (generatedConfiguration) => {
const loadersConfigs = [{
test: /\.vue$/, // vue
use: [{
loader: 'vue-loader'
}]
}, {
resourceQuery: /vue&type=script&lang=ts/, // typescript
loader: 'ts-loader',
options: {
appendTsSuffixTo: [/\.vue$/],
transpileOnly: true
}
}, {
resourceQuery: /vue&type=style.*&lang=scss/, // scss
use: [{
loader: themedStyleLoader,
options: {
async: true
}
},
{
loader: 'css-loader',
options: {
modules: true,
localIdentName: '[local]_[sha1:hash:hex:8]'
}
},
'sass-loader'
]
}];
generatedConfiguration.plugins.push(vuePlugin);
generatedConfiguration.plugins.push(forkTsPlugin);
generatedConfiguration.module.rules.push(...loadersConfigs);
return generatedConfiguration;
}
});
// register custom watch for Vue.JS files
// copy of '.vue' files will be handled by 'copy-static-assets.json'
gulp.watch('./src/**/*.vue', event => {
// copy empty index.ts onto itself to launch build procees
gulp.src('./src/index.ts')
.pipe(gulp.dest('./src/'));
});
build.initialize(gulp);