-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.common.js
64 lines (62 loc) · 1.8 KB
/
webpack.common.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
const path = require('path');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const CompressionPlugin = require('compression-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const HtmlWebpackTagsPlugin = require('html-webpack-tags-plugin');
module.exports = {
cache: {type: "filesystem"},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx'],
},
entry: "./src/index.tsx",
output: {
path: path.resolve(__dirname, "static"),
publicPath: "/s",
filename: "s.js",
},
module: {
rules: [
{
test: /\.(ts|tsx|js|jsx)$/,
exclude: /node_modules/,
use: {
loader: "babel-loader"
}
}
]
},
plugins: [
new ForkTsCheckerWebpackPlugin({
typescript: {memoryLimit: 256}
}),
new CopyPlugin({
patterns: [
{
from: 'src/static',
to: '.',
globOptions: {dot: true},
transform (content, path) {
if (path.endsWith(".css")) {
return content.toString().replace(/(\s)\s+/g, '$1')
}
return content
}
}
]
}),
new HtmlWebpackPlugin({
template: 'src/index.html',
inject: 'head',
hash: true,
}),
new HtmlWebpackTagsPlugin({
tags: ['s.css'],
append: false,
hash: true,
}),
new CompressionPlugin({
test: /\.(js|css|html|svg)(\?.*)?$/i,
}),
]
};