forked from pfgithub/threadclient
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
90 lines (88 loc) · 2.67 KB
/
webpack.config.js
File metadata and controls
90 lines (88 loc) · 2.67 KB
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
const path = require("path");
const CopyPlugin = require("copy-webpack-plugin");
const WorkboxPlugin = require("workbox-webpack-plugin");
const webpack = require("webpack");
const VirtualModulesPlugin = require("webpack-virtual-modules");
const dev = process.env.NODE_ENV === "development";
module.exports = {
entry: {
bundle: "./src/entry.ts",
darkmode: "./src/darkmode.js",
},
output: {
path: path.resolve(__dirname, "dist"),
filename: "[name].js",
},
mode: dev ? "development" : "production",
...(dev ? {devtool: "eval-cheap-module-source-map"} : {}),
module: {
rules: [{
test: /\.tsx?$/,
exclude: /node_modules/,
use: {loader: "babel-loader", options: {
presets: [
"@babel/preset-typescript",
["@babel/preset-env", {
targets: {browsers: ">10%"},
modules: false,
}],
"@babel/preset-react",
],
plugins: [
["@babel/plugin-proposal-pipeline-operator", {
proposal: "smart",
}],
],
}},
}, {
test: /\.(gif|svg|png)$/i,
use: [
"url-loader",
],
}, {
test: /\.p?css$/i,
use: [
"style-loader",
{loader: "css-loader", options: {importLoaders: 1}},
{loader: "postcss-loader"},
],
}, {
test: /\.s[ac]ss$/i,
use: [
"style-loader",
{loader: "css-loader", options: {importLoaders: 1}},
"postcss-loader",
"sass-loader"
],
}],
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
},
plugins: [
new webpack.DefinePlugin({
'fakevar.build': JSON.stringify(dev ? "development" : "production"),
}),
new CopyPlugin({
patterns: [
{from: "static", to: ""},
],
}),
...(dev ? [] : [new WorkboxPlugin.GenerateSW({
clientsClaim: true,
skipWaiting: true,
navigateFallback: "/index.html",
})]),
new VirtualModulesPlugin({
'node_modules/_variables.js': require("./src/_variables.js"),
}),
],
devServer: {
contentBase: path.join(__dirname, "dist"),
compress: true,
port: 3004,
historyApiFallback: true,
hot: true,
disableHostCheck: true, // it's open source, who cares
},
};