forked from xivanalysis/xivanalysis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.neutrinorc.js
231 lines (206 loc) · 5.96 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
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
const webpack = require('webpack')
const WebpackBar = require('webpackbar')
const envConfig = require('./config/env')
const jestConfig = require('./config/jest')
const nodeEnv = process.env.NODE_ENV || 'development'
const isDevelopment = nodeEnv === 'development'
const descriptionContent = 'Automated performance analysis and suggestion platform for Final Fantasy XIV: Shadowbringers.'
module.exports = {
options: {
root: __dirname,
},
use: [
// eslint config - we're just pulling in the rules from the main packages
require('@neutrinojs/eslint')({
eslint: {
baseConfig: {
extends: [
'plugin:@xivanalysis/recommended',
'plugin:@xivanalysis/client',
],
rules: {
'react/display-name': 'off',
'no-prototype-builtins': 'off',
}
},
},
}),
// Add TS extensions to the system ahead of time
neutrino => {
const {extensions} = neutrino.options
extensions.splice(0, 0, 'ts', 'tsx')
neutrino.options.extensions = extensions
},
// Set up lingui's loader before everything else because #reasons
neutrino => {
neutrino.config.module
.rule('lingui')
.test(/locale.+\.json$/)
.type('javascript/auto')
.use('lingui')
.loader('@lingui/loader')
},
// Main config preset
require('@neutrinojs/react')({
// Set up the generated index file
html: {
title: 'xivanalysis',
meta: [
{
name: 'viewport',
content: 'width=device-width, initial-scale=1, shrink-to-fit=no',
},
{ name: 'theme-color', content: '#000000' },
{ property: 'description', content: descriptionContent },
{ property: 'og:title', content: 'xivanalysis' },
{ property: 'og:description', content: descriptionContent },
{ property: 'og:type', content: 'website' },
{ property: 'og:image', content: '/og.jpg' },
{ property: 'og:url', content: 'https://xivanalysis.com' },
],
favicon: './public/logo.png',
},
// Basic options for css-loader
style: {
css: {
localsConvention: 'camelCase',
}
},
// Tweaks for babel
babel: {
plugins: [
'macros',
'lodash',
'@lingui/transform-js',
'./locale/babel-plugin-transform-react',
'@babel/proposal-optional-chaining',
'@babel/proposal-nullish-coalescing-operator',
],
},
// Tweaks for WDS, mostly to emulate react-scripts handling more-or-less
devServer: {
port: 3000,
overlay: true,
},
// Source map generation config
devtool: {
development: 'cheap-module-eval-source-map',
production: 'source-map',
test: 'source-map'
}
}),
// Add decorators. Have to do this manually as it needs to be before the stuff the react preset sets up
neutrino => {
neutrino.config.module
.rule('compile')
.use('babel')
.tap(options => ({
...options,
plugins: [
['@babel/plugin-proposal-decorators', {legacy: true}],
...options.plugins,
]
}))
},
// Load env vars. Not using the `env` option for react 'cus it doesn't expand the way I'd like it to
envConfig,
// Add module resolution using NODE_SRC_PATH so absolutes work
neutrino => {
const modules = neutrino.config.resolve.modules
modules.add(process.env.NODE_SRC_PATH)
modules.add('node_modules')
},
// Tweak the name mangling performed by css-loader
neutrino => {
neutrino.config.module
.rule('style').oneOf('modules').use('css')
.tap(options => ({
...options,
modules: {
...options.modules,
localIdentName: isDevelopment? '[name]_[local]__[md5:hash:base64:5]' : undefined,
}
}))
},
// Add typings for css-loader
neutrino => {
neutrino.config.module
.rule('style').oneOf('modules').use('css-types').before('css')
.loader('@teamsupercell/typings-for-css-modules-loader')
.options({
banner: '// This file is automatically generated. Do not edit.',
eol: '\n',
disableLocalsExport: true,
})
neutrino.config.plugin('ignore-css-types').use(new webpack.WatchIgnorePlugin([/module\.css\.d\.ts$/]))
},
// Set up postcss
neutrino => {
const postcssOptions = {
plugins: [
require('autoprefixer'),
require('postcss-modules-values-replace')({
resolve: {
modules: ['src'],
extensions: ['.css'],
},
}),
require('postcss-color-function')(),
require('postcss-calc'),
require('cssnano')({
preset: ['default', {
// Need to disable this, it mangles relative imports which freaks other loaders out
normalizeUrl: false,
}],
}),
require('postcss-modules-tilda'),
],
}
neutrino.config.module
.rule('style').oneOf('normal').use('postcss')
.loader('postcss-loader').options({postcssOptions})
neutrino.config.module
.rule('style').oneOf('modules').use('postcss')
.loader('postcss-loader').options({postcssOptions})
const addExtraImport = options => ({...options, importLoaders: options.importLoaders + 1})
neutrino.config.module
.rule('style').oneOf('normal').use('css')
.tap(addExtraImport)
neutrino.config.module
.rule('style').oneOf('modules').use('css')
.tap(addExtraImport)
},
// Set up TypeScript
neutrino => {
neutrino.config.module
.rule('compile')
.use('ts')
.loader('ts-loader')
.options({
onlyCompileBundledFiles: true,
})
neutrino.config.module
.rule('tslint')
.test(/\.tsx?$/)
.pre()
.use('tslint')
.loader('tslint-loader')
},
// Disable ES modules for images, we have synthetic imports, and use `require` on a bunch to inline code
neutrino => neutrino.config.module
.rule('image')
.use('url')
.tap(options => ({
...options,
esModule: false,
})),
// Copy static assets to the build directory
require('@neutrinojs/copy')({
patterns: ['public'],
}),
// Test stuff
jestConfig,
// WebpackBar because looking pretty is Important™
neutrino => neutrino.config.plugin('webpackbar').use(new WebpackBar()),
]
}