This repository was archived by the owner on Sep 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathwebpack.config.js
126 lines (125 loc) · 3.32 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
const production = process.env.NODE_ENV === 'production'
const staging = process.env.NODE_ENV === 'staging'
const debug = !production && !staging
const webpack = require('webpack')
const path = require('path')
const GitRevisionPlugin = require('git-revision-webpack-plugin')
const CleanWebpackPlugin = require('clean-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
module.exports = {
mode: production ? 'production' : 'development',
entry: {
polyfills: './src/polyfills.js',
eqip: './src/boot.jsx',
},
output: {
filename: '[name].[contenthash].js',
path: path.resolve(__dirname, 'dist', 'js'),
publicPath: '/js/',
},
resolve: {
extensions: ['.js', '.jsx'],
},
module: {
rules: [
{
test: /\.jsx?$/,
include: path.resolve(__dirname, 'src'),
use: ['cache-loader', 'babel-loader'],
},
{
test: /\.module\.scss$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
url: false,
sourceMap: true,
modules: true,
localIdentName: '[name]__[local]--[hash:base64:5]',
},
},
{
loader: 'sass-loader',
options: {
sourceMap: true,
includePaths: [path.resolve(__dirname, 'src', 'sass')],
},
},
{
loader: 'sass-resources-loader',
options: {
resources: [
'./node_modules/uswds/src/stylesheets/lib/addons/_font-stacks.scss',
'./node_modules/uswds/src/stylesheets/core/_variables.scss',
'./src/sass/_eqip-colors.scss',
'./src/sass/_eqip-fonts.scss',
],
},
},
],
},
{
test: /\.scss$/,
exclude: /\.module\.scss$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: { url: false, sourceMap: true },
},
{
loader: 'sass-loader',
options: {
sourceMap: true,
includePaths: [path.resolve(__dirname, 'src', 'sass')],
},
},
],
},
],
},
optimization: {
runtimeChunk: 'single',
splitChunks: {
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
chunks: 'all',
},
},
},
},
devtool: debug ? 'cheap-module-source-map' : 'source-map',
plugins: [
new webpack.EnvironmentPlugin([
'API_BASE_URL',
'HASH_ROUTING',
'BASIC_ENABLED',
'SAML_ENABLED',
'SAML_SLO_ENABLED',
'SESSION_TIMEOUT',
'ATTACHMENTS_ENABLED',
'FILE_MAXIMUM_SIZE',
'FILE_TYPES',
]),
new webpack.DefinePlugin({
EAPP_VERSION: JSON.stringify(
new GitRevisionPlugin({
versionCommand: 'describe --tags --always',
}).version()
),
}),
new CleanWebpackPlugin(['dist/js', 'dist/css']),
new MiniCssExtractPlugin({
filename: '../css/[name].[contenthash].css',
}),
new HtmlWebpackPlugin({
filename: '../index.html',
template: './src/index.html',
}),
],
}