-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.common.js
106 lines (105 loc) · 2.67 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
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
const path = require("path");
const webpack = require("webpack");
const IgnoreEmitPlugin = require("ignore-emit-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
module.exports = {
entry: {
content: ["./src/content/content.ts", "./src/content/content.scss"],
background: ["./src/background/background.ts"],
options: ["./src/options/options.ts", "./src/options/options.scss"],
popup: ["./src/popup/popup.ts", "./src/popup/popup.scss"],
},
output: {
path: path.resolve(__dirname, "dist"),
filename: "js/[name].js",
},
module: {
rules: [
{
test: /\.ts$/,
use: [
{
loader: "ts-loader",
options: {
// Make compilation faster with `fork-ts-checker-webpack-plugin`
transpileOnly: true,
},
},
],
exclude: /node_modules/,
},
{
test: /\.scss$/,
include: [path.resolve(__dirname, "src")],
use: [
MiniCssExtractPlugin.loader,
"css-loader",
"resolve-url-loader",
{
loader: "sass-loader",
options: {
sourceMap: true,
},
},
],
},
{
test: /\.html$/i,
loader: 'html-loader',
},
{
test: /\.(woff2?|ttf|otf|eot)/,
type: "asset/resource",
generator: {
filename: "fonts/[name][ext]",
},
},
{
test: /\.png/,
type: "asset/resource",
generator: {
filename: "images/[name][ext]",
},
},
],
},
plugins: [
new webpack.ProgressPlugin(),
new ForkTsCheckerWebpackPlugin(),
new CopyWebpackPlugin({
patterns: [
{
from: "locales",
to: "_locales/[name]/messages.json",
},
{
from: "assets/images/linotify_icon*",
to: "images/[name][ext]",
}
],
}),
new MiniCssExtractPlugin({
filename: "css/[name].css",
}),
new IgnoreEmitPlugin([/\/style.js$/, /\/*.LICENSE*/]),
new HtmlWebpackPlugin({
inject: true,
chunks: ["popup"],
filename: "popup.html",
template: "src/popup/popup.html",
}),
new HtmlWebpackPlugin({
inject: true,
chunks: ["options"],
filename: "options.html",
template: "src/options/options.html",
}),
//new FontPreloadPlugin(),
],
resolve: {
extensions: [".ts", ".js", ".scss"],
},
};