UNPKG

5.66 kBPlain TextView Raw
1import { create as berunJs } from '@berun/berun'
2import presetReact from '../src/preset-react'
3
4test('Gets Webpack plugin configuration', () => {
5 const berun = berunJs(presetReact)
6
7 expect(
8 berun.webpack.plugins.values().map(plugin => {
9 const c = plugin.toConfig()
10 return {
11 name: c.__pluginName,
12 args: c.__pluginArgs,
13 constructor: c.__pluginConstructorName
14 }
15 })
16 ).toEqual([
17 {
18 constructor: 'HtmlWebpackPlugin',
19 args: [
20 {
21 inject: true,
22 templateContent: expect.stringContaining('<!DOCTYPE html>')
23 }
24 ],
25 name: 'html'
26 },
27 {
28 name: 'interpolate-html',
29 constructor: 'InterpolateHtmlPlugin',
30 args: [
31 expect.any(Function),
32 {
33 NODE_ENV: 'test',
34 PUBLIC_URL: ''
35 }
36 ]
37 },
38 {
39 name: 'env',
40 constructor: 'DefinePlugin',
41 args: [
42 {
43 'process.env': {
44 NODE_ENV: '"test"',
45 APP_PATH: '"/Volumes/DATA/projects/berun/packages/runner-webpack"',
46 DIRECTORIES: '{}',
47 PUBLIC_URL: '""',
48 REMOTE_ORIGIN_URL: '"git@github.com:bestyled/berun.git"',
49 TITLE: '"@berun/runner-webpack"',
50 VERSION: expect.any(String),
51 WORKSPACE: '"/Volumes/DATA/projects/berun"'
52 }
53 }
54 ]
55 },
56 {
57 name: 'progress-bar',
58 constructor: 'ProgressBarPlugin',
59 args: expect.any(Array)
60 },
61 {
62 name: 'modulenotfound',
63 constructor: 'ModuleNotFoundPlugin',
64 args: ['/Volumes/DATA/projects/berun/packages/runner-webpack']
65 },
66 {
67 name: 'hot',
68 constructor: 'HotModuleReplacementPlugin',
69 args: []
70 },
71 {
72 name: 'case-sensitive-paths',
73 constructor: 'CaseSensitivePathsPlugin',
74 args: []
75 },
76 {
77 name: 'watch-missing-node-modules',
78 constructor: 'WatchMissingNodeModulesPlugin',
79 args: [
80 '/Volumes/DATA/projects/berun/packages/runner-webpack/node_modules'
81 ]
82 },
83 {
84 name: 'moment',
85 constructor: 'IgnorePlugin',
86 args: [/^\.\/locale$/, /moment$/]
87 },
88 {
89 name: 'manifest',
90 constructor: 'ManifestPlugin',
91 args: [
92 {
93 fileName: 'asset-manifest.json',
94 publicPath: '/'
95 }
96 ]
97 },
98 {
99 args: [
100 {
101 async: false,
102 tsconfig:
103 '/Volumes/DATA/projects/berun/packages/runner-webpack/tsconfig.json',
104 eslint: false
105 }
106 ],
107 constructor: 'ForkTsCheckerWebpackPlugin',
108 name: 'fork-ts-checker'
109 }
110 ])
111})
112
113test('Gets Webpack production plugin configuration', () => {
114 process.env.NODE_ENV = 'production'
115 const berun = berunJs(presetReact)
116
117 expect(
118 berun.webpack.plugins.values().map(plugin => {
119 const c = plugin.toConfig()
120 return {
121 name: c.__pluginName,
122 args: c.__pluginArgs,
123 constructor: c.__pluginConstructorName
124 }
125 })
126 ).toEqual([
127 {
128 constructor: 'HtmlWebpackPlugin',
129 args: [
130 {
131 inject: true,
132 templateContent: expect.stringContaining('<!DOCTYPE html>'),
133 minify: {
134 removeComments: true,
135 collapseWhitespace: true,
136 removeRedundantAttributes: true,
137 useShortDoctype: true,
138 removeEmptyAttributes: true,
139 removeStyleLinkTypeAttributes: true,
140 keepClosingSlash: true,
141 minifyJS: true,
142 minifyCSS: true,
143 minifyURLs: true
144 }
145 }
146 ],
147 name: 'html'
148 },
149 {
150 name: 'interpolate-html',
151 constructor: 'InterpolateHtmlPlugin',
152 args: [
153 expect.any(Function),
154 {
155 NODE_ENV: 'production',
156 PUBLIC_URL: ''
157 }
158 ]
159 },
160 {
161 name: 'env',
162 constructor: 'DefinePlugin',
163 args: [
164 {
165 'process.env': {
166 NODE_ENV: '"production"',
167 APP_PATH: '"/Volumes/DATA/projects/berun/packages/runner-webpack"',
168 DIRECTORIES: '{}',
169 PUBLIC_URL: '""',
170 REMOTE_ORIGIN_URL: '"git@github.com:bestyled/berun.git"',
171 TITLE: '"@berun/runner-webpack"',
172 VERSION: expect.any(String),
173 WORKSPACE: '"/Volumes/DATA/projects/berun"'
174 }
175 }
176 ]
177 },
178 {
179 name: 'progress-bar',
180 constructor: 'ProgressBarPlugin',
181 args: expect.any(Array)
182 },
183 {
184 name: 'modulenotfound',
185 constructor: 'ModuleNotFoundPlugin',
186 args: ['/Volumes/DATA/projects/berun/packages/runner-webpack']
187 },
188 /* {
189 name: 'workbox',
190 constructor: 'GenerateSW',
191 args: [
192 {
193 clientsClaim: true,
194 exclude: [/\.map$/, /asset-manifest\.json$/],
195 importWorkboxFrom: 'cdn',
196 navigateFallback: '/index.html',
197 navigateFallbackBlacklist: [
198 new RegExp('^/_'),
199 new RegExp('/[^/]+\\.[^/]+$')
200 ]
201 }
202 ]
203 }, */
204 {
205 name: 'moment',
206 constructor: 'IgnorePlugin',
207 args: [/^\.\/locale$/, /moment$/]
208 },
209 {
210 name: 'manifest',
211 constructor: 'ManifestPlugin',
212 args: [
213 {
214 fileName: 'asset-manifest.json',
215 publicPath: '/'
216 }
217 ]
218 },
219 {
220 args: [
221 {
222 async: false,
223 tsconfig:
224 '/Volumes/DATA/projects/berun/packages/runner-webpack/tsconfig.json',
225 eslint: false
226 }
227 ],
228 constructor: 'ForkTsCheckerWebpackPlugin',
229 name: 'fork-ts-checker'
230 }
231 ])
232})