-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathwebpack.config.js
More file actions
146 lines (133 loc) · 3.35 KB
/
webpack.config.js
File metadata and controls
146 lines (133 loc) · 3.35 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
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
require('dotenv').config();
const path = require('path');
const fs = require('fs');
const lessToJs = require('less-vars-to-js');
const {
EnvironmentPlugin,
} = require('webpack');
const devMode = process.env.NODE_ENV !== 'production';
const themeVariables = lessToJs(fs.readFileSync(path.join(__dirname, './src/styles/ant-vars.less'), 'utf8'));
const HTMLPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const { ProvidePlugin } = require('webpack');
const plugins = [
new EnvironmentPlugin({
DATABASE_URL: 'https://townhalltestingsms.firebaseio.com',
FIREBASE_API_KEY: 'AIzaSyCJncx2G6bUnecl4H2VHSBTDfRRxg7H5Fs',
FIREBASE_AUTH_DOMAIN: 'townhalltestingsms.firebaseapp.com',
MESSAGING_SENDER_ID: 86976100332,
PROJECT_ID: 'townhalltestingsms',
STORAGE_BUCKET: 'townhalltestingsms.appspot.com',
}),
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
chunkFilename: '[id].css',
filename: '[name].css',
publicPath: '/',
}),
new HTMLPlugin({
template: `${__dirname}/src/index.html`,
}),
// new ExtractPlugin('bundle.[hash].css'),
new CopyWebpackPlugin([
{
flatten: true,
from: 'src/assets/downloads/*.pdf',
to: 'downloads',
},
// {
// from: 'src/CNAME',
// },
{
flatten: true,
from: 'src/assets/images',
to: 'images',
},
]),
];
module.exports = {
mode: 'development',
plugins,
resolve: {
extensions: [".jsx", ".js", ".json"]
},
// Load this and everything it cares about
entry: `${__dirname}/src/main.js`,
devtool: 'source-map',
// Stick it into the "path" folder with that file name
output: {
filename: 'bundle.[hash].js',
path: `${__dirname}/build`,
publicPath: '/',
},
module: {
rules: [
// If it's a .js file not in node_modules, use the babel-loader
{
exclude: /node_modules/,
loader: 'babel-loader',
test: /\.js|.jsx?$/,
options: {
plugins: [
['import', { libraryName: 'antd', style: true }],
],
},
},
{
test: /\.(sa|sc|c)ss$/,
use: [
devMode ? 'style-loader' : MiniCssExtractPlugin.loader,
'css-loader',
'sass-loader',
],
},
{
test: /\.less$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
},
{
loader: 'less-loader',
options: {
javascriptEnabled: true,
modifyVars: themeVariables,
},
},
],
},
{
test: /\.(woff|woff2|ttf|eot|glyph|\.svg)$/,
use: [
{
loader: 'url-loader',
options: {
limit: 10000,
name: 'font/[name].[ext]',
},
},
],
},
{
test: /\.(jpg|jpeg|gif|png|tiff|svg)$/,
exclude: /\.glyph.svg/,
use: [
{
loader: 'url-loader',
options: {
limit: 6000,
name: 'images/[name].[ext]',
},
},
],
},
],
},
devServer: {
historyApiFallback: true,
host: '0.0.0.0'
},
};