-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
54 lines (48 loc) · 1.6 KB
/
webpack.config.js
File metadata and controls
54 lines (48 loc) · 1.6 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
const path = require('path');
const webpack = require('webpack');
// Libs
const HtmlWebpackPlugin = require('html-webpack-plugin');
// Configuration
module.exports = {
entry: path.join(__dirname, 'src', 'index.tsx'), // Entry point for bundling in ./src/index.js
output: {
path: path.resolve(__dirname, 'dist') // Output point of bundling in ./dist
},
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx'], // Allowed extensions
},
module: {
// Rule to transpile JS with Babel first
rules: [
{
test: /\.(js|jsx|ts|tsx)$/, // To transpile js files
exclude: /node_modules/, // Exclude node modules from transpiling
use: {
loader: 'babel-loader', // To use this package
options: {
presets: ['@babel/preset-env', '@babel/preset-react'] // Use these presets to transpile JS
}
}
},
{
test: /\.(mp4)$/,
use: {
loader: 'file-loader', // Setup file loader to allow videos / images in the project
options: {
name: '[name].[ext]'
}
}
}
]
},
plugins: [
// Setup html-webpack-plugin to generate index.html
new HtmlWebpackPlugin({
template: path.join(__dirname, 'index.html')
}),
// Provide React package to every file
new webpack.ProvidePlugin({
React: 'react'
})
]
}