forked from microsoft/FluidFramework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.base.js
More file actions
65 lines (60 loc) · 1.69 KB
/
Copy pathwebpack.base.js
File metadata and controls
65 lines (60 loc) · 1.69 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
/*!
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
* Licensed under the MIT License.
*/
const path = require('path');
module.exports.commonParams = { dir: './', distPath: 'dist/lib', merge: {} };
module.exports.BaseConfig = {
watch: false,
output: {
filename: '[name].js',
libraryTarget: 'umd',
// fixes the error discussed in this thread https://github.com/webpack/webpack/issues/6522
globalObject: 'typeof self !== \'undefined\' ? self : this'
},
resolve: {
extensions: ['.wasm', '.mjs', '.ts', '.tsx', '.js', '.jsx', '.json', '*'],
alias: {
src: path.join(process.cwd(), 'src')
}
},
module: {
rules: [
// All source files will have any sourcemaps re-processed by 'source-map-loader'.
{ enforce: 'pre', test: /\.[tj]sx?$/, exclude: /node_modules/, use: ['source-map-loader'] }
]
}
};
module.exports.TSConfig = function(fileType, generateDeclarations, distTypesPath, configFile = '', compilerOptions = {}) {
let tsConfig = {};
if (fileType === 'ts') {
if (generateDeclarations) {
compilerOptions.declarationDir = distTypesPath;
} else {
compilerOptions.declaration = false;
compilerOptions.declarationMap = false;
}
const options = {
experimentalWatchApi: true,
compilerOptions: compilerOptions
};
if (configFile) {
options.configFile = configFile;
}
tsConfig = {
module: {
rules: [
{
test: /\.tsx?$/,
exclude: [/node_modules/],
use: {
loader: require.resolve('ts-loader'),
options: options
}
}
]
}
};
}
return tsConfig;
};