-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
config.js
58 lines (47 loc) · 2.06 KB
/
config.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
var chai = require('chai')
, expect = chai.expect
, path = require('path')
var resolve = require('../index').resolve
var file = path.join(__dirname, 'files', 'src', 'jsx', 'dummy.js')
var extensionFile = path.join(__dirname, 'config-extensions', 'src', 'dummy.js')
var absoluteSettings = {
config: path.join(__dirname, 'files', 'some', 'absolute.path.webpack.config.js'),
}
describe("config", function () {
it("finds webpack.config.js in parent directories", function () {
expect(resolve('main-module', file)).to.have.property('path')
.and.equal(path.join(__dirname, 'files', 'src', 'main-module.js'))
})
it("finds absolute webpack.config.js files", function () {
expect(resolve('foo', file, absoluteSettings)).to.have.property('path')
.and.equal(path.join(__dirname, 'files', 'some', 'absolutely', 'goofy', 'path', 'foo.js'))
})
it("finds compile-to-js configs", function () {
var settings = {
config: path.join(__dirname, './files/webpack.config.babel.js'),
}
expect(resolve('main-module', file, settings))
.to.have.property('path')
.and.equal(path.join(__dirname, 'files', 'src', 'main-module.js'))
})
it("finds compile-to-js config in parent directories", function () {
expect(resolve('main-module', extensionFile))
.to.have.property('path')
.and.equal(path.join(__dirname, 'config-extensions', 'src', 'main-module.js'))
})
it("finds the first config with a resolve section", function () {
var settings = {
config: path.join(__dirname, './files/webpack.config.multiple.js'),
}
expect(resolve('main-module', file, settings)).to.have.property('path')
.and.equal(path.join(__dirname, 'files', 'src', 'main-module.js'))
})
it("finds the config at option config-index", function () {
var settings = {
config: path.join(__dirname, './files/webpack.config.multiple.js'),
'config-index': 2,
}
expect(resolve('foo', file, settings)).to.have.property('path')
.and.equal(path.join(__dirname, 'files', 'some', 'goofy', 'path', 'foo.js'))
})
})