-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwebpack.config.js
More file actions
executable file
·90 lines (83 loc) · 1.89 KB
/
webpack.config.js
File metadata and controls
executable file
·90 lines (83 loc) · 1.89 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
/**
* webpack config for the react app.
* @author gaurav
*/
const webpack = require('webpack');
const path = require('path');
const dotenv = require('dotenv');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const BUILD_DIR = path.resolve(__dirname, 'src/client/build');
const APP_DIR = path.resolve(__dirname, 'src/client/app');
dotenv.config();
// const env = dotenv.config().parsed;
// const envKeys = Object.keys(env).map((prev, next) => {
// prev[`process.env.${next}`] = JSON.stringify(env[next]);
// return prev;
// }, {});
const config = {
entry: `${APP_DIR}/index.js`,
output: {
path: BUILD_DIR,
filename: '[name].bundle.js',
},
devServer: {
contentBase: './src/client/build',
},
module: {
rules: [
{
test: /\.jsx?/,
include: APP_DIR,
loader: 'babel-loader',
},
{
test: /\.(sass|scss)$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: ['css-loader', 'sass-loader'],
}),
},
{
test: /\.css?/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.(jpe?g|png|gif|svg|ico)$/i,
loaders: [
'file-loader?hash=sha512&digest=hex&name=assets/images/[hash].[ext]',
{
loader: 'image-webpack-loader',
query: {
mozjpeg: {
progressive: true,
},
gifsicle: {
interlanced: false,
},
optipng: {
optimizationLevel: 4,
},
pngquant: {
quality: '75-90',
speed: 3,
},
},
},
],
exclude: '/node_modules/',
include: APP_DIR,
},
],
},
plugins: [
new HtmlWebpackPlugin({ template: './src/client/app/index.html' }),
new ExtractTextPlugin('[name].css'),
new webpack.DefinePlugin({
'process.env': {
URL: JSON.stringify(process.env.URL || process.env.URL_DEVELOPMENT),
},
}),
],
};
module.exports = config;