-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.dev.js
More file actions
102 lines (101 loc) · 3.3 KB
/
webpack.config.dev.js
File metadata and controls
102 lines (101 loc) · 3.3 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
const webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = {
module: {
rules: [
{
test: /\.(png|jpg|gif|svg|json)$/,
loader: 'file-loader',
options: {
publicPath: (url, resourcePath, context) => {
console.log(url);
console.log(resourcePath);
console.log(context);
// this section I didn't finish but it would load files based on public paths.
// I didn't need it for this demo.
},
}
},
{
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader
},
{
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
plugins: ['@babel/plugin-transform-react-jsx']
}
},
{
loader: 'css-loader',
options: {
importLoaders: 2,
sourceMap: true,
modules: false
}
},
'postcss-loader'
]
}
]
},
output: {
path: path.resolve(__dirname, 'dist'),
publicPath: '/',
filename: 'bundle.js'
},
plugins: [
new HtmlWebpackPlugin({
title:'Spectrum Rewards Demo',
minify:{
collapseWhitespace: true
},
hash: true,
template:'index.html'
}),
new webpack.HotModuleReplacementPlugin(),
new webpack.DefinePlugin({
'process.env':{
'API_URL': JSON.stringify('http://localhost:8080'),
'ASSET_PATH': JSON.stringify(''),
'ENVIRONMENT': JSON.stringify('development')
}
}),
new MiniCssExtractPlugin({
filename: "style[hash].css"
}),
// Here we could define any environment constants we need
new webpack.DefinePlugin({
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
DEBUG: JSON.stringify(process.env.DEBUG),
API_URL: JSON.stringify(process.env.API_URL), // defines the base API url for the dev env
}),
],
devServer: {
contentBase: path.join(__dirname, '/src'),
hot: true,
historyApiFallback: true,
allowedHosts: [
'localhost'
]
},
resolve: {
modules: [
path.resolve(__dirname + '/components'),
path.resolve(__dirname + '/data/'),
path.resolve(__dirname + '/context'),
path.resolve(__dirname + '/services'),
path.resolve(__dirname + '/node_modules'),
path.resolve(__dirname + '/assets')
]
},
resolveLoader: {
modules: ['node_modules'],
extensions: ['.jsx', '.js', '.json'],
}
};