-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.common.js
97 lines (95 loc) · 2.53 KB
/
webpack.common.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
93
94
95
96
97
const path = require('path');
const Dotenv = require('dotenv-webpack');
const FILE_LOADER = 'file-loader';
module.exports = {
entry: './src/index.jsx',
module: {
rules: [
{ parser: { requireEnsure: false } },
{
test: /\.(js|jsx|ts|tsx)$/,
enforce: 'pre',
use: [
{
options: {
cache: true,
eslintPath: 'eslint',
resolvePluginsRelativeTo: __dirname,
},
loader: 'eslint-loader',
},
],
include: path.resolve(__dirname, 'src'),
},
{
test: /\.(js|jsx)$/,
loader: 'babel-loader',
exclude: path.resolve(__dirname, 'node_modules'),
include: path.resolve(__dirname, 'src'),
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
include: path.resolve(__dirname, 'src'),
},
{
test: /\.(bmp|gif|jpe?g|png)$/,
use: [
{
loader: FILE_LOADER,
options: {
name: '[name].[sha512:hash:base64:7].[ext]',
outputPath: 'static/images',
},
},
],
include: path.resolve(__dirname, 'src'),
},
{
test: /\.(woff(2)?|ttf|eot|otf|svg)(\?v=\d+\.\d+\.\d+)?$/,
use: [
{
loader: FILE_LOADER,
options: {
name: '[name].[sha512:hash:base64:7].[ext]',
outputPath: 'static/fonts',
},
},
],
include: path.resolve(__dirname, 'src'),
},
{
test: /\.(wav|mp3)$/,
use: [
{
loader: FILE_LOADER,
options: {
name: 'static/audio/[name].[sha512:hash:base64:7].[ext]',
},
},
],
include: path.resolve(__dirname, 'src'),
},
],
},
resolve: {
extensions: ['*', '.js', '.jsx'],
alias: {
public: path.resolve(__dirname, 'public'),
app: path.resolve(__dirname, 'src/app'),
components: path.resolve(__dirname, 'src/components'),
locales: path.resolve(__dirname, 'src/locales'),
modules: path.resolve(__dirname, 'src/modules'),
pages: path.resolve(__dirname, 'src/pages'),
routes: path.resolve(__dirname, 'src/routes'),
services: path.resolve(__dirname, 'src/services'),
utils: path.resolve(__dirname, 'src/utils'),
},
},
output: {
path: path.resolve(__dirname, 'dist'),
publicPath: '/',
filename: 'bundle.js',
},
plugins: [new Dotenv()],
};