-
Notifications
You must be signed in to change notification settings - Fork 9
/
webpack.config.js
86 lines (82 loc) · 1.91 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
79
80
81
82
83
84
85
86
const path = require('path');
const webpack = require('webpack');
const yargs = require('yargs');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
let nodeModulesPath = path.resolve(__dirname, 'node_modules');
let libraryFilename = 'fatec-api',
plugins = [],
outputFile,
isProduction = yargs.argv.p;
if (isProduction) {
plugins.push(new webpack.optimize.UglifyJsPlugin({
minimize: true,
output: { comments: false },
sourceMap: false
}));
outputFile = libraryFilename + '.min.js';
} else {
outputFile = libraryFilename + '.js';
}
if (yargs.argv.d) {
plugins.push(new BundleAnalyzerPlugin());
}
function srcPath(subdir) {
return path.join(__dirname, "src", subdir);
}
module.exports = {
context: path.resolve("./src"),
target: 'node',
entry: './index.ts',
output: {
filename: outputFile,
libraryTarget: 'commonjs',
libraryExport: 'default',
path: path.resolve(__dirname, 'dist')
},
resolve: {
extensions: [".ts", ".js"],
alias: {
auth: srcPath('auth'),
core: srcPath('core'),
models: srcPath('models')
},
},
module: {
rules: [
{
'test': /\.tsx?$/,
'loaders': ['babel-loader','ts-loader'],
'exclude': [/(node_modules|dist)/, nodeModulesPath]
},
{
'test': /\.(jsx?)$/,
'loaders': ['babel'],
'exclude': [/(node_modules|dist)/, nodeModulesPath]
},
{
test: /\.ts$/,
use: [
{
loader: 'tslint-loader',
options: {
emitErrors: true,
failOnHint: true
}
}
],
enforce: 'pre',
exclude: /(node_modules|dist)/
}
]
},
externals : {
'request-promise-native': 'request-promise-native',
'cheerio': 'cheerio'
},
node: {
console: false,
fs: 'empty',
net: 'empty',
tls: 'empty'
}
};