Repository navigation
Expand file tree
/
Copy pathwebpack.config.js
More file actions
100 lines (96 loc) · 2.67 KB
/
Copy pathwebpack.config.js
File metadata and controls
100 lines (96 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
91
92
93
94
95
96
97
98
99
100
'use strict';
const webpack = require('webpack');
const path = require('path');
const rules = require('./webpack.rules');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ReactRefreshPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
const HOST = process.env.HOST || 'local.forio.com';
const PORT = process.env.PORT || '8888';
rules.push({
test: /\.css$/,
exclude: /[\/\\]src[\/\\]/,
use: [
{
loader: 'style-loader',
},
{
loader: 'css-loader',
},
],
});
rules.push({
test: /\.scss$/,
exclude: /[\/\\](node_modules|bower_components|public)[\/\\]/,
use: [
{
loader: 'style-loader',
},
{
loader: 'css-loader',
options: {
sourceMap: true,
importLoaders: 1,
},
},
{
loader: 'postcss-loader',
options: {
sourceMap: true,
},
},
{
loader: 'resolve-url-loader',
},
{
loader: 'sass-loader',
},
],
});
module.exports = {
mode: 'development',
entry: ['./src/index.jsx'],
devtool: process.env.WEBPACK_DEVTOOL || 'cheap-module-source-map',
output: {
path: path.join(__dirname, 'public'),
publicPath: `http://${HOST}:${PORT}/`,
filename: 'bundle.js',
},
resolve: {
alias: {
actions: path.resolve(__dirname, 'src', 'actions'),
components: path.resolve(__dirname, 'src', 'components'),
hooks: path.resolve(__dirname, 'src', 'hooks'),
static: path.resolve(__dirname, 'src', 'static'),
css: path.resolve(__dirname, 'src', 'static', 'css'),
selectors: path.resolve(__dirname, 'src', 'selectors'),
reducers: path.resolve(__dirname, 'src', 'reducers'),
utils: path.resolve(__dirname, 'src', 'utils'),
img: path.resolve(__dirname, 'src', 'static', 'img'),
},
extensions: ['.js', '.jsx'],
},
module: {
rules,
},
devServer: {
static: {
directory: './public',
},
// serve index.html in place of 404 responses to allow HTML5 history
historyApiFallback: true,
port: PORT,
host: HOST,
headers: { 'Access-Control-Allow-Origin': '*' },
allowedHosts: 'all',
proxy: {
'/': 'http://local.forio.com:9999',
},
},
plugins: [
new ReactRefreshPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new HtmlWebpackPlugin({
template: './src/template.html',
}),
],
};