UNPKG

1.86 kBPlain TextView Raw
1import { create as berunJs } from '@berun/berun'
2import presetReact from '../src/preset-react'
3
4test('Gets Webpack optimization configuration', () => {
5 const berun = berunJs(presetReact)
6
7 expect(berun.webpack.optimization.entries()).toEqual({
8 splitChunks: {
9 chunks: 'all',
10 name: false
11 },
12 runtimeChunk: true
13 })
14
15 expect(
16 berun.webpack.optimization.minimizers.values().map(plugin => {
17 const c = plugin.toConfig()
18 return {
19 name: c.__pluginName,
20 args: c.__pluginArgs,
21 constructor: c.__pluginConstructorName
22 }
23 })
24 ).toEqual([])
25})
26
27test('Gets Webpack production optimization configuration', () => {
28 process.env.NODE_ENV = 'production'
29 const berun = berunJs(presetReact)
30
31 expect(berun.webpack.optimization.entries()).toEqual({
32 splitChunks: {
33 chunks: 'all',
34 name: false
35 },
36 runtimeChunk: true,
37 minimize: true
38 })
39
40 expect(
41 berun.webpack.optimization.minimizers.values().map(plugin => {
42 const c = plugin.toConfig()
43 return {
44 name: c.__pluginName,
45 args: c.__pluginArgs,
46 constructor: c.__pluginConstructorName
47 }
48 })
49 ).toEqual([
50 {
51 name: 'terser',
52 constructor: 'TerserPlugin',
53 args: [
54 {
55 terserOptions: {
56 parse: {
57 ecma: 8
58 },
59 compress: {
60 ecma: 5,
61 warnings: false,
62 comparisons: false
63 },
64 mangle: {
65 safari10: true
66 },
67 output: {
68 ecma: 5,
69 comments: false,
70 // eslint-disable-next-line @typescript-eslint/camelcase
71 ascii_only: true
72 }
73 },
74 parallel: true,
75 cache: true,
76 sourceMap: false
77 }
78 ]
79 }
80 ])
81})