-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.neutrinorc.js
44 lines (35 loc) · 1.12 KB
/
.neutrinorc.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
const webpack = require("webpack")
const reactTSPreset = require("neutrino-preset-react-typescript")
const appConfig = require("config")
const customSourcemap = ({ config }) => {
config.when(!!process.env.SOURCEMAP, config => config.devtool(process.env.SOURCEMAP))
}
const defineGlobals = ({ config }) => {
const constants = appConfig.constants
if (!constants) {
return
}
const globals = {}
// JSON stringify all constants defined in config.constants.
// Since webpack.DefinePlugin splice these values as source code,
// we are effectively treating them as JS literals.
Object.keys(constants).map((key) => {
const val = constants[key]
globals[key] = JSON.stringify(val, null, " ")
})
config.plugin("globals")
.use(webpack.DefinePlugin, [globals])
}
module.exports = (neutrino, opts = {}) => {
neutrino.use(reactTSPreset, {
...opts,
html: {
links: [
"https://fonts.googleapis.com/css?family=Lato:100,100i,300,300i,400,400i,700,700i,900,900i",
],
},
devServer: { port: process.env.PORT || 3000 },
})
neutrino.use(customSourcemap)
neutrino.use(defineGlobals)
}