-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwebpack.config.js
78 lines (74 loc) · 2.76 KB
/
webpack.config.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
const path = require('path');
const webpack = require('webpack');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const ReplaceInFilePlugin = require('replace-in-file-webpack-plugin');
module.exports = () => {
return {
entry: { 'execute-webhint': './src/task/execute-webhint' },
/**
* We need development because otherwise we cannot transform the dynamic require
* the Azure librarie does for languages (see "ReplaceInFilePlugin" below)
*/
mode: 'development',
module: {
rules: [
{
test: /\.ts$/,
use: [{
loader: 'ts-loader',
options: { configFile: 'tsconfig.json' }
}]
}
]
},
node: {
__dirname: false,
__filename: false,
fs: true,
path: true,
process: false
},
output: { filename: 'task/[name].js' },
plugins: [
new ForkTsCheckerWebpackPlugin(),
new CopyPlugin([
{
from: './src/**/*.{json,png,html}',
transformPath: (path) => {
return path.replace('src/', '');
}
},
// These files are needed by azure-pipelines-task-lib library. See: https://github.com/shudv/azure-pipelines-task-template/blob/master/webpack.config.js
{
from: path.join(__dirname, './node_modules/azure-pipelines-task-lib/lib.json'),
to: path.join(__dirname, './dist/task')
},
{
from: path.join(__dirname, './node_modules/azure-pipelines-task-lib/Strings'),
to: path.join(__dirname, './dist/task/Strings')
}
]),
new ReplaceInFilePlugin([
// This replacement is required to allow azure-pipelines-task-lib to load the
// json resource file correctly
{
dir: 'dist/task',
files: ['execute-webhint.js'],
rules: [
{
search: /__webpack_require__\(\\\"\.\/node_modules\/azure-pipelines-task-lib sync recursive\\\"\)\(resourceFile\);/,
replace: 'require(resourceFile)'
}
]
}
]),
new webpack.ProgressPlugin()
],
resolve: {
modules: ['node_modules'],
extensions: ['.ts', '.js']
},
target: 'node'
};
};