-
-
Notifications
You must be signed in to change notification settings - Fork 198
/
manifest.js
72 lines (58 loc) · 2.31 KB
/
manifest.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
/*
* This file is part of the Symfony Webpack Encore package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
'use strict';
const expect = require('chai').expect;
const { WebpackManifestPlugin } = require('webpack-manifest-plugin');
const WebpackConfig = require('../../lib/WebpackConfig');
const RuntimeConfig = require('../../lib/config/RuntimeConfig');
const manifestPluginUtil = require('../../lib/plugins/manifest');
function createConfig() {
const runtimeConfig = new RuntimeConfig();
runtimeConfig.context = __dirname;
runtimeConfig.babelRcFileExists = false;
const config = new WebpackConfig(runtimeConfig);
config.setPublicPath('/foo');
return config;
}
describe('plugins/manifest', () => {
it('default settings', () => {
const config = createConfig();
const plugins = [];
manifestPluginUtil(plugins, config);
expect(plugins.length).to.equal(1);
expect(plugins[0].plugin).to.be.instanceof(WebpackManifestPlugin);
expect(plugins[0].plugin.options.fileName).to.equal('manifest.json');
});
it('with options callback', () => {
const config = createConfig();
const plugins = [];
config.configureManifestPlugin((options) => {
options.fileName = 'bar';
});
manifestPluginUtil(plugins, config);
expect(plugins.length).to.equal(1);
expect(plugins[0].plugin).to.be.instanceof(WebpackManifestPlugin);
// Allows to override default options
expect(plugins[0].plugin.options.fileName).to.equal('bar');
});
it('with options callback that returns an object', () => {
const config = createConfig();
const plugins = [];
config.configureManifestPlugin((options) => {
options.fileName = 'bar';
// This should override the original config
return { foo: true };
});
manifestPluginUtil(plugins, config);
expect(plugins.length).to.equal(1);
expect(plugins[0].plugin).to.be.instanceof(WebpackManifestPlugin);
expect(plugins[0].plugin.options.fileName).to.equal('manifest.json');
expect(plugins[0].plugin.options.foo).to.equal(true);
});
});