-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwebpack.config.base.js
More file actions
97 lines (94 loc) · 2.42 KB
/
webpack.config.base.js
File metadata and controls
97 lines (94 loc) · 2.42 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
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
'use strict'
var webpack = require('webpack')
var path = require('path')
var MiniCssExtractPlugin = require('mini-css-extract-plugin')
var CopyFilesPlugin = require('copy-webpack-plugin')
var ManifestPlugin = require('webpack-manifest-plugin')
var dependencies = require('./package.json').dependencies
module.exports = {
entry: {
app: [path.join(__dirname, 'src', 'client.js')],
vendor: Object.keys(dependencies)
},
output: {
path: path.join(__dirname, 'dist'),
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx']
},
devtool: 'inline-source-map',
module: {
noParse: /\.min\.js/,
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: []
}
}
},
{
test: /\.tsx?$/,
exclude: /node_modules/,
use: {
loader: 'ts-loader',
}
},
{
test: /\.(graphql|gql)$/,
exclude: /node_modules/,
use: 'graphql-tag/loader'
},
{ test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, use: 'url?limit=10000&mimetype=application/font-woff' },
{ test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/, use: 'url?limit=10000&mimetype=application/font-woff' },
{ test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, use: 'url?limit=10000&mimetype=image/svg+xml' },
{ test: /\.jpg$/, use: 'url-loader?limit=100000' },
{ test: /\.png$/, use: 'url-loader?limit=100000' },
{ test: /\.gif$/, use: 'url-loader?limit=100000' },
{ test: /\.jpg$/, use: 'file-loader' },
{
test: /\.css$/,
use: [
{ loader: MiniCssExtractPlugin.loader },
'css-loader',
]
}
]
},
plugins: [
new CopyFilesPlugin([{
from: './src/images',
to: './images'
}]),
new webpack.NoEmitOnErrorsPlugin(),
new webpack.SourceMapDevToolPlugin({
filename: '[name].js.map'
}),
new MiniCssExtractPlugin({
filename: 'vendor.css'
}),
new ManifestPlugin({
fileName: 'stats.json',
// Exclude sourcemaps
filter: ({name}) => {
if (name.endsWith('js') || name.endsWith('css')) return true
return false
}
}),
],
optimization: {
splitChunks: {
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendor',
chunks: 'initial',
enforce: true,
},
}
}
}
}