-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.ts
62 lines (58 loc) · 1.86 KB
/
webpack.config.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
import path from 'path';
import webpack from 'webpack';
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
import NodemonPlugin from 'nodemon-webpack-plugin';
import ModuleDependencyWarning from 'webpack/lib/ModuleDependencyWarning';
const nodeEnv = process.env.NODE_ENV || 'development';
const isProd = nodeEnv === 'production';
class IgnoreNotFoundExportPlugin {
apply(compiler) {
const messageRegExp = /export '.*'( \(reexported as '.*'\))? was not found in/;
function doneHook(stats) {
stats.compilation.warnings = stats.compilation.warnings.filter(function(warn) {
if (warn instanceof ModuleDependencyWarning && messageRegExp.test(warn.message)) {
return false;
}
return true;
});
}
if (compiler.hooks) {
compiler.hooks.done.tap('IgnoreNotFoundExportPlugin', doneHook);
} else {
compiler.plugin('done', doneHook);
}
}
}
const webpackconfiguration: webpack.Configuration = {
entry: path.resolve(__dirname, 'src', 'axios-morphism.ts'),
devtool: isProd ? 'hidden-source-map' : 'source-map',
externals: {
morphism: 'morphism'
},
output: {
filename: 'axios-morphism.js',
path: path.resolve('./dist'),
libraryTarget: 'umd',
globalObject: 'this',
sourceMapFilename: 'axios-morphism.map',
library: 'AxiosMorphism'
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.json']
},
module: {
rules: [{ test: /\.(ts|js)x?$/, use: ['babel-loader', 'source-map-loader'], exclude: /node_modules/ }]
},
plugins: [
new ForkTsCheckerWebpackPlugin({
async: false,
checkSyntacticErrors: true,
reportFiles: ['**', '!**/*.json', '!**/__tests__/**', '!**/?(*.)(spec|test).*'],
watch: './src',
silent: true
}),
new NodemonPlugin(),
new IgnoreNotFoundExportPlugin()
]
};
export default webpackconfiguration;