Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bf28e94
commit c24eb04
Showing
12 changed files
with
171 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
it("should contain only black", function() { | ||
require.context('./test1', true, /\.less$/); | ||
require('./test2/shared.less'); | ||
/*const style = getComputedStyle(document.body); | ||
expect(style.color).toBe(" black"); | ||
expect(style.background).toBe(" black");*/ | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require.context('./test1', true, /\.less$/); | ||
require('./test2/shared.less'); | ||
|
||
it("should contain only white", function() { | ||
const style = getComputedStyle(document.body); | ||
|
||
expect(style.color).toBe(" white"); | ||
expect(style.background).toBe(" white"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module.exports = { | ||
moduleScope(scope) { | ||
const light = scope.window.document.createElement("link"); | ||
light.rel = "stylesheet"; | ||
light.href = "light.css"; | ||
scope.window.document.head.appendChild(light); | ||
}, | ||
findBundle: function () { | ||
return ["./light.js"]; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
body { | ||
color: @color; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
body { | ||
background: @color; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** @type {import("../../../../").Configuration} */ | ||
module.exports = { | ||
target: "web", | ||
entry: { | ||
light: { import: "./light.js", layer: "light" }, | ||
dark: { import: "./dark.js", layer: "dark" } | ||
}, | ||
experiments: { | ||
layers: true, | ||
css: true | ||
}, | ||
output: { | ||
filename: "[name].js" | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.less$/i, | ||
type: "css/auto", | ||
oneOf: [ | ||
{ | ||
issuerLayer: "light", | ||
use: [ | ||
{ | ||
loader: "less-loader", | ||
options: { | ||
additionalData: "@color: white;" | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
issuerLayer: "dark", | ||
use: [ | ||
{ | ||
loader: "less-loader", | ||
options: { | ||
additionalData: "@color: black;" | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require.context('./test1', true, /\.less$/); | ||
require('./test2/shared.less'); | ||
|
||
it("should contain only black", function() { | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
|
||
const source = fs.readFileSync(path.join(__dirname, "dark.css"), "utf-8"); | ||
|
||
expect(source.match(/black/g)).toHaveLength(2); | ||
expect(source).not.toContain("white"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require.context('./test1', true, /\.less$/); | ||
require('./test2/shared.less'); | ||
|
||
it("should contain only white", function() { | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
|
||
const source = fs.readFileSync(path.join(__dirname, "light.css"), "utf-8"); | ||
|
||
expect(source.match(/white/g)).toHaveLength(2); | ||
expect(source).not.toContain("black"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
findBundle: function () { | ||
return ["./light.js", "./dark.js"]; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.test1 { | ||
color: @color; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.test2 { | ||
color: @color; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
const MiniCssExtractPlugin = require("mini-css-extract-plugin"); | ||
|
||
/** @type {import("../../../../").Configuration} */ | ||
module.exports = { | ||
entry: { | ||
light: { import: "./light.js", layer: "light" }, | ||
dark: { import: "./dark.js", layer: "dark" } | ||
}, | ||
experiments: { | ||
layers: true | ||
}, | ||
output: { | ||
filename: "[name].js" | ||
}, | ||
plugins: [ | ||
new MiniCssExtractPlugin({ | ||
filename: "[name].css" | ||
}) | ||
], | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.less$/i, | ||
oneOf: [ | ||
{ | ||
issuerLayer: "light", | ||
use: [ | ||
MiniCssExtractPlugin.loader, | ||
"css-loader", | ||
{ | ||
loader: "less-loader", | ||
options: { | ||
additionalData: "@color: white;" | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
issuerLayer: "dark", | ||
use: [ | ||
MiniCssExtractPlugin.loader, | ||
"css-loader", | ||
{ | ||
loader: "less-loader", | ||
options: { | ||
additionalData: "@color: black;" | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
}; |