-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug/issue 1346 bundle transitive CSS
url(...)
references (#1348)
- Loading branch information
1 parent
f77b894
commit 14de0b7
Showing
10 changed files
with
123 additions
and
37 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
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
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
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
1 change: 1 addition & 0 deletions
1
packages/cli/test/cases/build.config.optimization-default/src/foo/bar.baz
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 @@ | ||
some file |
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
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 |
---|---|---|
|
@@ -26,7 +26,7 @@ import fs from 'fs'; | |
import glob from 'glob-promise'; | ||
import { JSDOM } from 'jsdom'; | ||
import path from 'path'; | ||
import { getOutputTeardownFiles } from '../../../../../test/utils.js'; | ||
import { getOutputTeardownFiles, getDependencyFiles } from '../../../../../test/utils.js'; | ||
import { Runner } from 'gallinago'; | ||
import { fileURLToPath, URL } from 'url'; | ||
|
||
|
@@ -49,7 +49,29 @@ describe('Build Greenwood With: ', function() { | |
let dom; | ||
|
||
before(async function() { | ||
runner.setup(outputPath); | ||
// this package has a known issue with import.meta.resolve | ||
// in that it has no main, module, or exports so it has to be hoisted | ||
// at least for this current version | ||
// https://unpkg.com/browse/[email protected]/package.json | ||
// https://github.com/FortAwesome/Font-Awesome/pull/19041 | ||
const fontAwesomePackageJson = await getDependencyFiles( | ||
`${process.cwd()}/node_modules/font-awesome/package.json`, | ||
`${outputPath}/node_modules/font-awesome/` | ||
); | ||
const fontAwesomeCssFiles = await getDependencyFiles( | ||
`${process.cwd()}/node_modules/font-awesome/css/*`, | ||
`${outputPath}/node_modules/font-awesome/css/` | ||
); | ||
const fontAwesomeFontFiles = await getDependencyFiles( | ||
`${process.cwd()}/node_modules/font-awesome/fonts/*`, | ||
`${outputPath}/node_modules/font-awesome/fonts/` | ||
); | ||
|
||
runner.setup(outputPath, [ | ||
...fontAwesomePackageJson, | ||
...fontAwesomeCssFiles, | ||
...fontAwesomeFontFiles | ||
]); | ||
runner.runCommand(cliPath, 'build'); | ||
|
||
dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, 'index.html')); | ||
|
@@ -141,10 +163,22 @@ describe('Build Greenwood With: ', function() { | |
expect(contents.indexOf(':root,:host{--spectrum-global-animation-linear:cubic-bezier(0, 0, 1, 1);')).to.equal(0); | ||
}); | ||
}); | ||
|
||
describe('<link rel="stylesheet" href="..."> with reference to transient relative node_modules url(...) references', function() { | ||
it('should have the expected number of font files referenced in vendor CSS file in the output directory', async function() { | ||
expect(await glob.promise(path.join(this.context.publicDir, 'node_modules/font-awesome/fonts/*'))).to.have.lengthOf(5); | ||
}); | ||
|
||
it('should have the expected url link for the bundled font-awesome file', async function() { | ||
const themeFile = await glob.promise(path.join(this.context.publicDir, 'styles/theme.*.css')); | ||
const contents = fs.readFileSync(themeFile[0], 'utf-8'); | ||
|
||
expect(contents.indexOf('@font-face {font-family:\'FontAwesome\';src:url(\'/node_modules/font-awesome/fonts/fontawesome-webfont.139345087.eot?v=4.7.0\');') > 0).to.equal(true); | ||
}); | ||
}); | ||
}); | ||
|
||
after(function() { | ||
runner.teardown(getOutputTeardownFiles(outputPath)); | ||
}); | ||
|
||
}); |
3 changes: 2 additions & 1 deletion
3
packages/cli/test/cases/build.default.import-node-modules/src/styles/theme.css
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
@import url('/node_modules/@spectrum-web-components/styles/all-large-dark.css'); | ||
@import url('/node_modules/@spectrum-web-components/styles/all-large-dark.css'); | ||
@import url('/node_modules/font-awesome/css/font-awesome.css'); |
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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
/* source-sans-pro-regular - latin */ | ||
/* intentionally mixing paths for CSS bundling testing */ | ||
@font-face { | ||
font-family: 'Source Sans Pro'; | ||
font-style: normal; | ||
font-weight: 400; | ||
font-display: swap; | ||
src: local('Source Sans Pro Regular'), local('SourceSansPro-Regular'), | ||
url('/assets/fonts/source-sans-pro-v13-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */ | ||
url('/assets/fonts/source-sans-pro-v13-latin-regular.woff') format('woff'), /* Modern Browsers */ | ||
url('/assets/fonts/source-sans-pro-v13-latin-regular.ttf') format('truetype'); /* Safari, Android, iOS */ | ||
url('./source-sans-pro-v13-latin-regular.woff') format('woff'), /* Modern Browsers */ | ||
url('./source-sans-pro-v13-latin-regular.ttf') format('truetype'); /* Safari, Android, iOS */ | ||
} |
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