-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
75 lines (71 loc) · 1.79 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
const path = require('path')
const typescriptIsTransformer = require('typescript-is/lib/transform-inline/transformer').default
const nodeExternals = require('webpack-node-externals')
const webpack = require('webpack')
const packageJson = require('./package.json')
module.exports = (env) => ({
mode: 'development',
devtool: 'source-map',
target: 'node',
node: {
__dirname: true,
__filename: true,
},
entry: {
index: './src/index.ts',
},
output: {
path: path.resolve(__dirname, 'build'),
filename: '[name].js',
library: 'scrape-pages',
libraryTarget: 'umd',
},
resolve: {
extensions: ['.ts', '.js'],
alias: {
'@scrape-pages': path.resolve(__dirname, 'src'),
'@test': path.resolve(__dirname, 'test'),
},
},
module: {
rules: [
{
test: (content) => env === 'coverage' && /\.ts$/.test(content),
include: path.resolve(__dirname, 'src'),
exclude: [/node_modules/, /\.test\.ts$/, /query-debugger\.ts$/],
loader: 'istanbul-instrumenter-loader',
options: { esModules: true },
enforce: 'post',
},
{
test: /\.ts$/,
exclude: /node_modules/,
loader: 'ts-loader',
options: {
getCustomTransformers: (program) => ({
before: [
typescriptIsTransformer(program, {
ignoreFunctions: true,
ignoreMethods: true,
disallowSuperfluousObjectProperties: true,
}),
],
}),
},
},
{
test: /\.ne$/,
loader: 'nearley-loader',
},
],
},
optimization: {
minimize: false,
},
plugins: [
new webpack.DefinePlugin({
VERSION: JSON.stringify(packageJson.version),
}),
],
externals: [nodeExternals()],
})