-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
73 lines (68 loc) · 1.85 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
// Visual BB, Copyright: (c) 2020, Najmeddine Nouri
// GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
var path = require('path');
var PROD = process.env.npm_lifecycle_event === 'build-p';
// plugins
var TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
var { CleanWebpackPlugin } = require('clean-webpack-plugin');
var ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
var outDir = rootPath('public/js/');
// join and return absolute path
function rootPath( /*path parts*/) {
return path.join.apply(
null,
[__dirname].concat(Array.prototype.slice.call(arguments, 0))
).replace(/\\/g, '/');
}
module.exports = {
context: rootPath('src'),
mode: PROD ? 'production' : 'development',
devtool: 'source-map',
entry: './main.ts', // main app
output: {
path: outDir,
filename: '[name].js',
publicPath: PROD ? '/' : 'http://localhost:8080/',
},
resolve: {
// only discover files that have those extensions
extensions: ['.ts', '.js'],
plugins: [new TsconfigPathsPlugin({
configFile: rootPath('./src/tsconfig.json')
})]
},
module: {
rules: [
// support for .ts files.
{
test: /\.ts$/,
loader: 'ts-loader',
options: {
// disable type checker - we will use it in fork plugin
transpileOnly: true
},
}
]
},
plugins: [
new CleanWebpackPlugin({
verbose: false
}),
new ForkTsCheckerWebpackPlugin()
],
stats: {
colors: true,
modules: false
},
// dev server configuration
devServer: {
contentBase: './public',
historyApiFallback: true,
quiet: false,
stats: 'minimal',
host: '127.0.0.1',
headers: {
'Access-Control-Allow-Origin': '*'
}
}
}