-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
58 lines (57 loc) · 1.74 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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
entry: './src/index.tsx', // string | object | array
// Here the application starts executing
// and webpack starts bundling
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'index_bundle.js',
publicPath: '/'
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx'],
modules: ['node_modules', path.join(__dirname, 'src')]
},
module: {
rules: [
{
test: /\.css$/,
exclude: /\.module\.css$/,
use: [{ loader: 'style-loader' }, { loader: 'css-loader' }]
},
{
test: /\.module\.css$/,
use: [
{ loader: 'style-loader' },
{
loader: 'css-loader',
options: { modules: true }
}
]
},
{
test: /\.(js|ts|jsx|tsx)$/,
exclude: /(node_modules)/,
use: 'babel-loader'
}
]
/* Advanced module configuration (click to show) */
},
devtool: 'eval-source-map',
devServer: {
historyApiFallback: true, // true for index.html upon 404, object for multiple paths
port: 3000,
onListening: function (devServer) {
const port = devServer.server.address().port;
console.log('Listening on port:', port);
}, //Provides an option to execute a custom function when webpack-dev-server starts listening for connections on a port.
open: true // Tells dev-server to open the browser after server had been started. Set it to true to open your default browser.
}, // list of additional plugins
plugins: [
new HtmlWebpackPlugin({
template: 'src/index.html'
})
]
};