-
Notifications
You must be signed in to change notification settings - Fork 7
/
nwb.config.js
74 lines (64 loc) · 1.74 KB
/
nwb.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
/*
* START_FEATURE django_react
*/
const path = require('path')
const BundleTracker = require('webpack-bundle-tracker')
/**
* Entry point configuration.
*
* This is where you should configure your webpack entry points, for example, a different entry point per page.
*/
const ENTRIES = {
// TODO delete me; this is just a reference example
Home: './src/Pages/Home.js',
Hello: './src/Components/Hello.js'
}
const SHARED_ENTRIES = [
// we have not included react-app-polyfill in this sample application because it is not technically required for
// projects which do not require polyfill. However, we do recommend installing and uncommenting this line of code
// for projects which will need to have guaranteed functionality on older browsers.
// './node_modules/react-app-polyfill/ie11.js',
]
/**
* nwb config
*/
module.exports = function({command}) {
/* Set config */
const config = {
type: 'react-app',
}
config.webpack = {
config(webpackConfig) {
// Set new entry configuration
webpackConfig.entry = {}
Object.keys(ENTRIES).forEach((entryKey) => {
webpackConfig.entry[entryKey] = [...SHARED_ENTRIES, ENTRIES[entryKey]]
})
return webpackConfig
},
extra: {
output: {
filename: '[name].js',
chunkFilename: '[name].js',
path: path.resolve('./static/webpack_bundles/'),
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'django-react-loader',
},
],
},
plugins: [
new BundleTracker({filename: './webpack-stats.json'}),
],
},
publicPath: '/static/webpack_bundles/',
}
return config
}
/*
* END_FEATURE django_react
*/