-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebpack.config.js
110 lines (109 loc) · 2.87 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
const path = require('path');
const fs = require('fs');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
.BundleAnalyzerPlugin;
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const HtmlWebpackInlineSVGPlugin = require('html-webpack-inline-svg-plugin');
const uglifycss = require('uglifycss');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const FaviconsWebpackPlugin = require('favicons-webpack-plugin');
module.exports = {
target: 'web',
entry: {
index: './src/index.ts',
},
devtool: 'source-map',
resolve: {
extensions: ['.ts', '.tsx', '.js'],
fallback: {
buffer: require.resolve('buffer'),
crypto: false,
stream: require.resolve('stream-browserify'),
},
},
module: {
rules: [
{
test: /\.ts(x?)$/,
exclude: /node_modules/,
use: [
{
loader: 'ts-loader',
options: {
transpileOnly: true,
experimentalWatchApi: true,
},
},
],
},
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
{
enforce: 'pre',
test: /\.js$/,
loader: 'source-map-loader',
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
},
{
test: /\.ttf$/,
use: ['file-loader'],
},
],
},
plugins: [
new MonacoWebpackPlugin({
// typescriptServices.js causes a warning in webpack
// Module not found: Error: Can't resolve '@microsoft/typescript-etw'
// https://github.com/microsoft/monaco-editor/issues/1623
languages: ['typescript'],
}),
new CleanWebpackPlugin(),
new ForkTsCheckerWebpackPlugin(),
new FaviconsWebpackPlugin({
logo: './assets/icon.png',
cache: true,
inject: true,
favicons: {
icons: {
android: false,
appleIcon: false,
appleStartup: false,
coast: false,
favicons: true,
firefox: false,
opengraph: false,
twitter: false,
yandex: false,
windows: false,
},
},
}),
new HtmlWebpackPlugin({
template: path.resolve(__dirname, 'src/index.html'),
templateParameters: {
indexCssInlineStyleTag: `<style>${uglifycss.processString(
fs.readFileSync('./src/index.css').toString(),
{}
)}</style>`,
},
}),
new HtmlWebpackInlineSVGPlugin(),
new BundleAnalyzerPlugin({
analyzerMode: 'static',
openAnalyzer: false,
}),
],
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'build'),
},
ignoreWarnings: [
{
module: /phosphor/,
},
],
};