-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.common.js
104 lines (101 loc) · 2.81 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
98
99
100
101
102
103
104
const path = require('path')
const CleanWebpackPlugin = require('clean-webpack-plugin') // eslint-disable-line import/no-extraneous-dependencies
const HtmlWebpackPlugin = require('html-webpack-plugin') // eslint-disable-line import/no-extraneous-dependencies
const HtmlWebpackPluginConfig = new HtmlWebpackPlugin({
template: `${__dirname}/app/index.html`,
filename: 'index.html',
inject: 'body',
})
module.exports = {
entry: {
app: './app/index.jsx',
},
resolve: {
extensions: ['*', '.js', '.jsx'],
},
plugins: [
new CleanWebpackPlugin(['dist']),
HtmlWebpackPluginConfig,
],
output: {
// filename: '[hash].bundle.js',
filename: '[name].[contenthash].js',
path: path.resolve(__dirname, 'dist'),
publicPath: '/',
},
module: {
rules: [
{
test: /\.txt|google2d5a70150f443732\.html$/,
loader: 'file-loader?name=[name].[ext]', // robots.txt, sitemap.txt, google verification file
},
// {
// test: /\.html$/,
// loader: 'html-loader',
// },
{
test: /favicon\.ico/,
use: 'file-loader?name=images/[name].[ext]',
},
{
test: /\.ya?ml$/,
use: 'js-yaml-loader',
},
{
test: /\.svg$/,
include: [
path.resolve(__dirname, 'app/images/meteo'),
/node_modules/,
],
loader: 'svg-url-loader',
options: {
// Inline files smaller than 10 kB (10240 bytes)
limit: 10 * 1024,
// Remove the quotes from the url
// (they’re unnecessary in most cases)
noquotes: true,
name: 'images/[name].[ext]',
},
// use: 'svg-url-loader?limit=10000&name=images/[name].[ext]',
},
{
test: /\.svg$/,
exclude: [
path.resolve(__dirname, 'app/images/meteo'),
/node_modules/,
],
// issuer: {
// test: /\.js$/,
// },
use: [
{ loader: '@svgr/webpack' },
// {
// loader: 'svg-url-loader',
// options: {
// // Inline files smaller than 10 kB (10240 bytes)
// limit: 10 * 1024,
// // Remove the quotes from the url
// // (they’re unnecessary in most cases)
// noquotes: true,
// },
// },
],
},
{
test: /\.(jpe?g|gif|png|webp|m4v)$/,
include: path.resolve(__dirname, 'app/images'),
use: 'url-loader?limit=5000&name=images/[name].[ext]',
},
// {
// test: /\.(eot|ttf|woff|woff2|svg)$/,
// include: path.resolve(__dirname, 'app/font'),
// use: 'file-loader?name=font/[name].[ext]',
// },
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: 'babel-loader',
},
],
},
}