/
webpack.config.ts
95 lines (93 loc) · 2.21 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
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
import path from "path";
import webpack from "webpack";
import CleanWebpackPlugin from "clean-webpack-plugin";
import MiniCssExtractPlugin from "mini-css-extract-plugin";
import OptimizeCssAssetsPlugin from "optimize-css-assets-webpack-plugin";
import TerserPlugin from "terser-webpack-plugin";
import WebpackManifestPlugin from "webpack-manifest-plugin";
const config: webpack.Configuration = {
entry: {
convert: "./web/convert/convert.ts",
index: "./web/index.ts",
renderChords: "./web/renderChords.ts",
showAllSongs: "./web/showAllSongs.ts",
editSongs: "./web/editSongs.ts",
parser: "./lib/parser.ts",
global: "./web/global.ts",
},
output: {
filename: "[name].[contenthash].bundle.js",
path: path.resolve(__dirname, "static", "dist"),
publicPath: "/static/dist/",
},
module: {
rules: [
{
test: /\.(?:js|ts)$/,
exclude: /node_modules/,
loader: "babel-loader",
},
{
test: /\.mustache$/,
loader: "mustache-loader",
},
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: "css-loader",
options: {
importLoaders: 1,
sourceMap: true,
},
},
{
loader: "postcss-loader",
options: {
sourceMap: true,
},
},
],
},
{
test: /\.(eot|png|svg|ttf|woff|woff2)$/,
loader: "url-loader",
options: {
limit: 8192,
},
},
],
},
node: false,
optimization: {
minimizer: [
new OptimizeCssAssetsPlugin({
cssProcessorOptions: {
map: true,
},
}),
new TerserPlugin({
sourceMap: true,
}),
],
},
plugins: [
new CleanWebpackPlugin(["static/dist"]),
new MiniCssExtractPlugin({
filename: "[name].[contenthash].css",
chunkFilename: "[id].[contenthash].css",
}),
new WebpackManifestPlugin({
publicPath: "/static/dist/",
}),
new webpack.ProvidePlugin({
jQuery: "jquery",
}),
],
resolve: {
extensions: [".ts", ".js"],
},
devtool: "source-map",
};
export default config;