forked from akiver/cs-demo-manager.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
111 lines (102 loc) · 2.65 KB
/
webpack.config.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
107
108
109
110
111
const path = require('path') // eslint-disable-line
const HtmlWebpackPlugin = require('html-webpack-plugin') // eslint-disable-line
const MiniCssExtractPlugin = require('mini-css-extract-plugin') // eslint-disable-line
const CopyPlugin = require('copy-webpack-plugin') // eslint-disable-line
module.exports = (env, { mode = 'development' }) => {
const isProduction = mode === 'production'
return {
devtool: isProduction ? false : 'cheap-module-source-map',
entry: {
polyfills: './src/polyfills.ts',
index: './src/index.tsx',
},
mode,
output: {
path: path.join(__dirname, 'dist'),
publicPath: isProduction ? '' : '/',
filename: '[name].bundle.js',
},
resolve: {
extensions: ['.ts', '.tsx', '.js'],
},
devServer: {
port: 4000,
overlay: true,
historyApiFallback: true,
disableHostCheck: true,
},
module: {
rules: [
{
test: /\.tsx?$/,
use: 'babel-loader',
exclude: /node_modules/,
},
{
test: /\.js$/,
use: 'babel-loader',
include: [
path.join(__dirname, 'node_modules/react-intl'),
path.join(__dirname, 'node_modules/intl-messageformat'),
path.join(__dirname, 'node_modules/intl-messageformat-parser'),
],
},
{
test: /\.(sa|sc|c)ss$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
},
{
loader: 'sass-loader',
options: {
sourceMap: true,
},
},
],
},
{
test: /\.md$/i,
use: 'raw-loader',
},
{
test: /\.svg$/,
use: ['@svgr/webpack'],
},
{
test: /\.(png)$/i,
use: [
{
loader: 'file-loader',
options: {
name: '[path][name].[hash].[ext]',
},
},
{
loader: 'image-webpack-loader',
options: {
disable: isProduction === false,
},
},
],
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: 'public/index.html',
title: 'CSGO Demos Manager',
favicon: 'public/favicon.ico',
}),
new CopyPlugin([
{ from: 'src/images/docs', to: 'docs' },
{ from: 'public/robots.txt', to: '.' },
]),
new MiniCssExtractPlugin({
filename: 'css/[name].bundle.css',
chunkFilename: '[id].css',
}),
],
}
}