annotate babel.config.js @ 472:b26dd8fa1c26 bootstrap-4

Update link to source
author nanaya <me@nanaya.pro>
date Sun, 23 Feb 2020 22:42:15 +0900
parents 802dcd44188e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
468
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
1 module.exports = function(api) {
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
2 var validEnv = ['development', 'test', 'production']
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
3 var currentEnv = api.env()
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
4 var isDevelopmentEnv = api.env('development')
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
5 var isProductionEnv = api.env('production')
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
6 var isTestEnv = api.env('test')
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
7
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
8 if (!validEnv.includes(currentEnv)) {
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
9 throw new Error(
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
10 'Please specify a valid `NODE_ENV` or ' +
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
11 '`BABEL_ENV` environment variables. Valid values are "development", ' +
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
12 '"test", and "production". Instead, received: ' +
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
13 JSON.stringify(currentEnv) +
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
14 '.'
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
15 )
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
16 }
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
17
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
18 return {
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
19 presets: [
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
20 isTestEnv && [
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
21 '@babel/preset-env',
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
22 {
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
23 targets: {
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
24 node: 'current'
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
25 }
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
26 }
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
27 ],
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
28 (isProductionEnv || isDevelopmentEnv) && [
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
29 '@babel/preset-env',
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
30 {
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
31 forceAllTransforms: true,
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
32 useBuiltIns: 'entry',
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
33 corejs: 3,
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
34 modules: false,
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
35 exclude: ['transform-typeof-symbol']
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
36 }
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
37 ]
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
38 ].filter(Boolean),
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
39 plugins: [
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
40 'babel-plugin-macros',
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
41 '@babel/plugin-syntax-dynamic-import',
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
42 isTestEnv && 'babel-plugin-dynamic-import-node',
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
43 '@babel/plugin-transform-destructuring',
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
44 [
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
45 '@babel/plugin-proposal-class-properties',
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
46 {
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
47 loose: true
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
48 }
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
49 ],
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
50 [
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
51 '@babel/plugin-proposal-object-rest-spread',
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
52 {
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
53 useBuiltIns: true
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
54 }
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
55 ],
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
56 [
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
57 '@babel/plugin-transform-runtime',
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
58 {
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
59 helpers: false,
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
60 regenerator: true,
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
61 corejs: false
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
62 }
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
63 ],
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
64 [
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
65 '@babel/plugin-transform-regenerator',
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
66 {
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
67 async: false
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
68 }
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
69 ]
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
70 ].filter(Boolean)
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
71 }
802dcd44188e Now with webpacker
nanaya <me@nanaya.pro>
parents:
diff changeset
72 }