Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add %PUBLIC_URL% support * Add %PUBLIC_URL% to documentation
- Loading branch information
Showing
11 changed files
with
92 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
build | ||
node_modules |
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,18 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const execa = require('execa'); | ||
|
||
it('buildOptions.baseUrl', () => { | ||
// %PUBLIC_URL% gets replaced with this setting | ||
execa.sync('npm', ['run', 'TEST'], {cwd: __dirname}); | ||
|
||
const outputHTML = fs.readFileSync(path.resolve(__dirname, 'build', 'index.html'), 'utf8'); | ||
|
||
const iconMatch = outputHTML.match(/<link rel="icon" href="([^"]+)/)[1]; | ||
const cssMatch = outputHTML.match(/<link rel="stylesheet" type="text\/css" href="([^"]+)/)[1]; | ||
const jsMatch = outputHTML.match(/<script type="module" src="([^"]+)/)[1]; | ||
|
||
expect(iconMatch).toBe('/static/favicon.ico'); | ||
expect(cssMatch).toBe('/static/index.css'); | ||
expect(jsMatch).toBe('/static/_dist_/index.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,16 @@ | ||
{ | ||
"scripts": { | ||
"start": "node ../../../pkg/dist-node/index.bin.js dev", | ||
"TEST": "node ../../../pkg/dist-node/index.bin.js build" | ||
}, | ||
"snowpack": { | ||
"scripts": { | ||
"mount:public": "mount public --to /", | ||
"mount:src": "mount src --to /_dist_" | ||
}, | ||
"buildOptions": { | ||
"baseUrl": "/static/" | ||
} | ||
}, | ||
"dependencies": {} | ||
} |
Binary file not shown.
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,14 @@ | ||
#img { | ||
display: block; | ||
margin: auto; | ||
height: 128px; | ||
width: 128px; | ||
padding: 2rem; | ||
} | ||
|
||
#canvas { | ||
display: block; | ||
margin: 2rem auto; | ||
width: 540px; | ||
height: 540px; | ||
} |
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,24 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<meta name="description" content="Web site created using create-snowpack-app" /> | ||
<link rel="stylesheet" type="text/css" href="%PUBLIC_URL%/index.css" /> | ||
<title>Snowpack App</title> | ||
</head> | ||
<body> | ||
<script type="module" src="%PUBLIC_URL%/_dist_/index.js"></script> | ||
<!-- | ||
This HTML file is a template. | ||
If you open it directly in the browser, you will see an empty page. | ||
You can add webfonts, meta tags, or analytics to this file. | ||
The build step will place the bundled scripts into the <body> tag. | ||
To begin the development, run `npm start` or `yarn start`. | ||
To create a production bundle, use `npm run build` or `yarn build`. | ||
--> | ||
</body> | ||
</html> |
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 @@ | ||
export default function doNothing() { | ||
// I do nothing 🎉 | ||
} |