forked from dptools/dpdash
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
executable file
·92 lines (89 loc) · 2.26 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
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
require('@babel/register')
const path = require('path')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const CopyPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const webpack = require('webpack')
const outputDirectory = 'public'
module.exports = {
target: 'web',
mode: process.env.NODE_ENV || 'production',
entry: './views/index.js',
watchOptions: {
ignored: ['**/node_modules', '**/server'],
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: [/node_modules/, /\.test\.(js|jsx)$/],
use: [
{
loader: 'babel-loader',
options: {
plugins: [
'react-html-attrs',
'@babel/plugin-proposal-class-properties',
['@babel/plugin-proposal-decorators', { legacy: true }],
['@babel/plugin-transform-runtime', { legacy: true }],
],
presets: [
[
'@babel/preset-react',
{
runtime: 'automatic',
},
],
'@babel/preset-env',
],
cacheDirectory: true,
},
},
],
},
{
test: /\.(png|svg|jpg|jpeg|gif)$/i,
type: 'asset/resource',
generator: {
filename: 'static/[hash][ext][query]',
},
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
},
],
},
optimization: {
minimize: process.env.NODE_ENV === 'production',
},
output: {
path: path.join(__dirname, outputDirectory),
filename: 'js/bundle.js',
publicPath: '/',
},
resolve: {
fallback: {
fs: false,
net: false,
tls: false,
},
extensions: ['*', '.js', '.jsx'],
},
devtool: 'source-map',
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
DPDASH_VERSION: JSON.stringify(process.env.npm_package_version),
},
}),
new CleanWebpackPlugin(),
new CopyPlugin({
patterns: [{ from: 'assets', to: 'img' }],
}),
new HtmlWebpackPlugin({
template: './template/template.html',
}),
],
}