-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.ts
83 lines (78 loc) · 1.61 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
//'use strict'
import webpack from "webpack";
import TerserPlugin from "terser-webpack-plugin";
import * as path from "path";
import { UserScriptHeaderPlugin } from "./config/header";
const packageJson = require("./package.json");
const node_env = () => {
switch (process.env.NODE_ENV) {
case "production":
return "production";
case "development":
return "development";
default:
return "none";
}
};
const config: webpack.Configuration = {
mode: node_env(),
entry: "./src/index.ts",
output: {
path: path.resolve(__dirname, "dist"),
filename: `${packageJson.name}.user.js`
},
resolve: {
extensions: [".js", ".ts", ".css", ".scss"]
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
},
{
test: /\.ts$/,
exclude: /node_modules/,
use: [
{
loader: "ts-loader",
}
]
},
{
test: /\.s?css$/,
exclude: /node_modules/,
use: [
"style-loader",
"css-loader",
"sass-loader"
]
},
{
test: /\.(png|jpg|gif)$/i,
use: ['url-loader']
}
]
},
optimization: {
minimize: process.env.MINIMIZER === "TRUE" ? true : false,
minimizer: [
new TerserPlugin({
terserOptions: {
ecma: 2015,
beautify: false
}
})
]
},
plugins: [
new UserScriptHeaderPlugin()
]
};
export default config;