Skip to content

Commit

Permalink
Fix public/ folder
Browse files Browse the repository at this point in the history
  • Loading branch information
cezaraugusto committed Sep 17, 2024
1 parent 414009d commit b26fdc9
Show file tree
Hide file tree
Showing 17 changed files with 34 additions and 35 deletions.
2 changes: 1 addition & 1 deletion examples/config-eslint/newtab/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<h1>
<img
class="eslint"
src="../public/logo.svg"
src="/logo.svg"
alt="The ESLint logo"
width="120px"
/>
Expand Down
2 changes: 1 addition & 1 deletion examples/config-lint/newtab/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<h1>
<img
class="logo"
src="../public/logo.png"
src="/logo.png"
alt="The Extension.js logo"
width="120px"
/>
Expand Down
2 changes: 1 addition & 1 deletion examples/config-prettier/newtab/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<h1>
<img
class="prettier"
src="../public/logo.svg"
src="/logo.svg"
alt="The Prettier logo"
width="120px"
/>
Expand Down
2 changes: 1 addition & 1 deletion examples/content-env/content/scripts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import dotenvLogo from '../public/logo.png'
import dotenvLogo from '/logo.png'
import './styles.css'

console.log(
Expand Down
3 changes: 1 addition & 2 deletions examples/content-esm/content/contentComponent.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import jsLogo from '../public/logo.png'
import extensionJsLogo from '../images/extension_128.png'

const contentComponent = `<div class="content_script-box">
<div class="content_script-header">
<img class="content_script-logo" src=${jsLogo} />
<img class="content_script-logo" src="/logo.png" />
<span>+</span>
<img class="content_script-logo" src=${extensionJsLogo} />
</div>
Expand Down
2 changes: 1 addition & 1 deletion examples/declarative_net_request/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
{
"id": "public_rule_1",
"enabled": true,
"path": "public/public_ruleset.json"
"path": "/public_ruleset.json"
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion examples/new-crypto/newtab/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<body>
<header>
<h1>
<img class="crypto" src="../public/logo.svg" alt="The Crypto Template logo" width="120px" />
<img class="crypto" src="/logo.svg" alt="The Crypto Template logo" width="120px" />
<br />
Welcome to your Crypto Extension.
</h1>
Expand Down
2 changes: 1 addition & 1 deletion examples/new-env/newtab/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<body>
<header>
<h1>
<img class="env" src="../public/logo.png" alt="The .env logo" width="120px" />
<img class="env" src="/logo.png" alt="The .env logo" width="120px" />
<br />
Welcome to your $EXTENSION_PUBLIC_DESCRIPTION_TEXT.
</h1>
Expand Down
2 changes: 1 addition & 1 deletion examples/special-folders-pages/pages/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ <h1>Main Window</h1>
<p>I am the main window. I am not sandboxed.</p>
<img src="../images/notpublic-file.png" alt="Not Public File" />
<iframe src="../sandbox/index.html" width="380" height="140"></iframe>
<iframe src="/public/html/file.html" width="380" height="140"></iframe>
<iframe src="/html/file.html" width="380" height="140"></iframe>
<script src="./main.js"></script>
</body>
</html>
4 changes: 2 additions & 2 deletions examples/special-folders-pages/sandbox/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<title>Sandboxed Content</title>
<link rel="stylesheet" href="../public/css/file.css" />
<link rel="stylesheet" href="/css/file.css" />
<link rel="stylesheet" href="./styles.css" />
</head>
<body>
Expand All @@ -19,6 +19,6 @@ <h1>Sandboxed Content</h1>
</script>
<iframe src="../pages/custom.html"></iframe>
<script src="./scripts.js"></script>
<script src="../public/js/file.js"></script>
<script src="/js/file.js"></script>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('HtmlPlugin (default behavior)', () => {

const sandboxHtml = path.join(outputPath, 'sandbox', 'page-0.html')
const pagesHtml = path.join(outputPath, 'pages', 'main.html')
const excludedHtml = path.join(outputPath, 'public', 'html', 'file.html')
const excludedHtml = path.join(outputPath, '/', 'html', 'file.html')

describe('html', () => {
it('should output HTML files for HTML paths defined in MANIFEST.JSON', async () => {
Expand All @@ -74,14 +74,14 @@ describe('HtmlPlugin (default behavior)', () => {
})

it('should resolve paths of HTML files for HTML paths defined in EXCLUDE option', async () => {
await findStringInFile(pagesHtml, '/public/html/file.html')
await findStringInFile(pagesHtml, '/html/file.html')
})
})

describe('css', () => {
const sandboxCss = path.join(outputPath, 'sandbox', 'page-0.css')
const pagesCss = path.join(outputPath, 'pages', 'main.css')
const excludedCss = path.join(outputPath, 'public', 'css', 'file.css')
const excludedCss = path.join(outputPath, '/', 'css', 'file.css')

it('should output CSS files for HTML paths defined in MANIFEST.JSON', async () => {
await assertFileIsEmitted(sandboxCss)
Expand All @@ -104,14 +104,14 @@ describe('HtmlPlugin (default behavior)', () => {
})

it('should resolve paths of CSS files for HTML paths defined in EXCLUDE option', async () => {
await findStringInFile(sandboxHtml, '/public/css/file.css')
await findStringInFile(sandboxHtml, '/css/file.css')
})
})

describe('js', () => {
const sandboxJs = path.join(outputPath, 'sandbox', 'page-0.js')
const pagesJs = path.join(outputPath, 'pages', 'main.js')
const excludedJs = path.join(outputPath, 'public', 'js', 'file.js')
const excludedJs = path.join(outputPath, '/', 'js', 'file.js')

it('should output JS files for HTML paths defined in MANIFEST.JSON', async () => {
await assertFileIsEmitted(sandboxJs)
Expand All @@ -134,14 +134,14 @@ describe('HtmlPlugin (default behavior)', () => {
})

it('should resolve paths of JS files for HTML paths defined in EXCLUDE option', async () => {
await findStringInFile(sandboxHtml, '/public/js/file.js')
await findStringInFile(sandboxHtml, '/js/file.js')
})
})

describe('static assets', () => {
const assetsPng = path.join(outputPath, 'assets', 'extension_128.png')
const pageAssetsPng = path.join(outputPath, 'assets', 'notpublic-file.png')
const excludedPng = path.join(outputPath, 'public', 'img', 'icon.png')
const excludedPng = path.join(outputPath, '/', 'img', 'icon.png')

it('should output PNG files for HTML paths defined in MANIFEST.JSON', async () => {
await assertFileIsEmitted(assetsPng)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class CopyPublicFolder {
if (!fs.existsSync(staticDir)) return

compiler.hooks.afterEmit.tap('special-folders:copy-public-folder', () => {
const target = path.join(output, 'public')
const target = path.join(output, '/')

if (!fs.existsSync(target)) fs.mkdirSync(target, {recursive: true})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"type": "module"
},
"icons": {
"16": "./public/logo.png",
"48": "./public/logo.png",
"128": "./public/logo.png"
"16": "/logo.png",
"48": "/logo.png",
"128": "/logo.png"
},
"permissions": ["management", "tabs", "storage"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"type": "module"
},
"icons": {
"16": "./public/logo.png",
"48": "./public/logo.png",
"128": "./public/logo.png"
"16": "/logo.png",
"48": "/logo.png",
"128": "/logo.png"
},
"permissions": ["management", "tabs", "storage"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"type": "module"
},
"icons": {
"16": "./public/logo.png",
"48": "./public/logo.png",
"128": "./public/logo.png"
"16": "/logo.png",
"48": "/logo.png",
"128": "/logo.png"
},
"permissions": ["management", "tabs", "storage"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"type": "module"
},
"icons": {
"16": "./public/logo.png",
"48": "./public/logo.png",
"128": "./public/logo.png"
"16": "/logo.png",
"48": "/logo.png",
"128": "/logo.png"
},
"permissions": ["management", "tabs", "storage"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"type": "module"
},
"icons": {
"16": "./public/logo.png",
"48": "./public/logo.png",
"128": "./public/logo.png"
"16": "/logo.png",
"48": "/logo.png",
"128": "/logo.png"
},
"permissions": ["management", "tabs", "storage"]
}

0 comments on commit b26fdc9

Please sign in to comment.