Skip to content

Commit

Permalink
fix: remove fonts from dist folder (#394)
Browse files Browse the repository at this point in the history
* fix: remove fonts from dist folder

* chore: install http-server for playwright
  • Loading branch information
SgtPooki authored Oct 22, 2024
1 parent 98659e2 commit 86641e5
Show file tree
Hide file tree
Showing 4 changed files with 302 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .aegir.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ export default {
// .css deps aren't checked properly.
'ipfs-css',
'tachyons',

// playwright dependencies
'http-server'
],
productionIgnorePatterns: [
'webpack.config.js',
Expand Down
22 changes: 17 additions & 5 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ function gitRevision () {
return `no-git-dirty@${new Date().getTime().toString()}`
}
}

/**
* Inject the dist/index.js and dist/index.css into the dist/index.html file
*
Expand Down Expand Up @@ -129,6 +130,21 @@ const modifyBuiltFiles = {
}
}

/**
* @param {string[]} extensions - The extension of the imported files to exclude. Must match the fill ending path in the import(js) or url(css) statement.
* @returns {esbuild.Plugin}
*/
const excludeFilesPlugin = (extensions) => ({
name: 'exclude-files',
setup (build) {
build.onResolve({ filter: /.*/ }, async (args) => {
if (extensions.some(ext => args.path.endsWith(ext))) {
return { path: args.path, namespace: 'exclude', external: true }
}
})
}
})

/**
* @type {esbuild.BuildOptions}
*/
Expand All @@ -139,10 +155,6 @@ export const buildOptions = {
loader: {
'.js': 'jsx',
'.css': 'css',
'.eot': 'file',
'.otf': 'file',
'.woff': 'file',
'.woff2': 'file',
'.svg': 'file'
},
minify: true,
Expand All @@ -153,7 +165,7 @@ export const buildOptions = {
format: 'esm',
entryNames: 'ipfs-sw-[name]-[hash]',
assetNames: 'ipfs-sw-[name]-[hash]',
plugins: [renameSwPlugin, modifyBuiltFiles]
plugins: [renameSwPlugin, modifyBuiltFiles, excludeFilesPlugin(['.eot?#iefix', '.otf', '.woff', '.woff2'])]
}

const ctx = await esbuild.context(buildOptions)
Expand Down
Loading

0 comments on commit 86641e5

Please sign in to comment.