forked from siggame/Viseur
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.ts
108 lines (107 loc) · 3.38 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
96
97
98
99
100
101
102
103
104
105
106
107
108
import * as HtmlWebpackPlugin from "html-webpack-plugin";
import { join, resolve } from "path";
import * as webpack from "webpack";
export default (// tslint:disable-line:no-default-export
env: undefined,
options: webpack.Configuration,
): webpack.Configuration => ({
entry: [
"@babel/polyfill/dist/polyfill.js", // polyfill new ES functions for babel
"font-awesome/scss/font-awesome.scss", // font-awesome icons injection
"src/index.ts", // our actual starting file now that stuff is ready
],
resolve: {
extensions: [".tsx", ".ts", ".js"],
alias: {
src: resolve(__dirname, "src/"),
},
},
output: {
filename: "js/[name].js",
path: resolve(__dirname, "dist"),
},
module: {
rules: [
{
test: /\.ts(x?)$/,
exclude: /node_modules/,
use: [
{
loader: "babel-loader",
options: {
babelrc: true,
},
},
{
loader: "ts-loader",
options: {
compilerOptions: {
// Keep es6+ imports in place for babel to handle.
// This allows the lodash treeshakers to work.
// This also means we are relying fully on babel for ESNext --> ES5 (or lower)
module: "esnext",
},
},
},
],
},
{
test: /\.(jpe?g|png|gif|ico|svg|ttf|otf|eot|woff|woff2)$/i,
use: [
{
loader: "file-loader",
options: {
outputPath: "resources/",
},
},
],
},
{
test: /\.hbs$/,
use: {
loader: "handlebars-loader",
options: {
helperDirs: [ join(__dirname, "/src/handlebars-") ],
inlineRequires: "\/images\/",
},
},
},
{
test: /\.(css|sass|scss)$/,
use: [
{
loader: "style-loader", // creates style nodes from JS strings
},
{
loader: "css-loader", // translates CSS into CommonJS
},
{
loader: "sass-loader", // compiles Sass to CSS
},
],
},
],
},
node: {
fs: "empty",
},
plugins: [
// generate for us our index.html page
new HtmlWebpackPlugin({
title: "Viseur",
minify: {
collapseWhitespace: true,
},
}) as any, // tslint:disable-line:no-any no-unsafe-any
],
optimization: {
sideEffects: true,
usedExports: true,
},
devtool: options.mode === "development"
? "inline-source-map"
: false,
performance: {
hints: false, // TODO: handle these warnings
},
});