-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.common.js
More file actions
43 lines (41 loc) · 1.36 KB
/
webpack.common.js
File metadata and controls
43 lines (41 loc) · 1.36 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
const CopyPlugin = require('copy-webpack-plugin');
const { config } = require('dotenv');
const HTMLWebpackPlugin = require('html-webpack-plugin');
const { join, resolve } = require('path');
const { DefinePlugin } = require('webpack');
config();
module.exports = {
devtool: 'inline-source-map',
entry: resolve(__dirname, 'src', 'index.tsx'),
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
module: {
rules: [
{
loader: 'babel-loader',
test: /\.(js|ts)x?$/,
},
],
},
output: {
chunkFilename: '[name].bundle.js',
filename: '[name].bundle.js',
path: resolve(__dirname, 'public'),
},
plugins: [
new CopyPlugin([
{ from: 'assets', to: '.' }
]),
new DefinePlugin({
'process.env.GITHUB_ACCESS_TOKEN': JSON.stringify(process.env.GITHUB_ACCESS_TOKEN),
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
}),
new HTMLWebpackPlugin({
filename: process.env.NODE_ENV === 'production' ? join('..', 'index.html') : 'index.html',
inject: 'body',
template: resolve(__dirname, 'templates', 'index.html'),
}),
],
resolve: {
extensions: ['.js', '.jsx', '.mjs', '.ts', '.tsx', '.css', '.sass', '.json'],
},
};