-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
65 lines (62 loc) · 1.58 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
const fs = require('fs');
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
// Make sure any symlinks in the project folder are resolved:
// https://github.com/facebook/create-react-app/issues/637
const appDirectory = fs.realpathSync(process.cwd());
const resolvePath = relativePath => path.resolve(appDirectory, relativePath);
module.exports = {
mode: 'development',
entry: './index.js',
output: {
filename: 'bundle.js'
},
module: {
rules: [
{
test: /\.(js|mjs|jsx|ts|tsx)$/,
include: resolvePath('.'),
loader: require.resolve('babel-loader'),
options: {
babelrc: false,
configFile: false,
presets: [
require.resolve('@babel/preset-env'),
require.resolve('@babel/preset-react')
]
}
},
{
test: /\.css$/,
include: resolvePath('.'),
use: [
require.resolve('style-loader'),
require.resolve('css-loader')
]
},
{
test: /\.(png|jpe?g|gif|svg)$/i,
include: resolvePath('.'),
use: [
{
loader: require.resolve('file-loader')
}
]
}
]
},
devtool: 'eval-cheap-module-source-map',
plugins: [
new webpack.ProvidePlugin({
React: require.resolve('react'),
ReactDOM: require.resolve('react-dom')
}),
new HtmlWebpackPlugin({
template: path.resolve(__dirname, 'template.html')
})
],
devServer: {
static: resolvePath('dist')
}
};