Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use two-step build #115

Merged
merged 22 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 72 additions & 2 deletions .aegir.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,77 @@
import { readFile } from 'fs/promises'
import { copy } from 'esbuild-plugin-copy'

// Define paths
const paths = {
src: 'dist-tsc',
public: 'public',
dist: 'dist-esbuild'
}

/**
* @type {import ('esbuild').Plugin}
*/
export const CSSMinifyPlugin = {
name: "CSSMinifyPlugin",
setup(build) {
build.onLoad({ filter: /\.css$/ }, async (args) => {
const f = await readFile(args.path)
const css = await transform(f, { loader: "css", minify: true })
return { loader: "text", contents: css.code }
})
}
}

// Copy plugin configuration
const copyPlugin = copy({
assets: [
{
from: [
`${paths.public}/_redirects`,
`${paths.public}/favicon.ico`,
`${paths.public}/index.html`,
],
to: ['./public']
},
{
from: [
`${paths.src}/**/*.svg`,
`${paths.src}/**/*.css`
],
to: ['.']
}
]
})

/** @type {import('aegir').PartialOptions} */
export default {
build: {
config: {
banner: {},
footer: {},
entryPoints: [`${paths.src}/src/index.jsx`, `${paths.src}/src/sw.js`],
minify: false,
splitting: true,
format: 'esm',
outdir: paths.dist,
chunkNames: 'ipfs-sw-[name]',
loader: {
'.svg': 'dataurl'
},
sourcemap: true,
plugins: [copyPlugin],
define: { 'process.env.NODE_ENV': '"production"' }
}
},
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need the results of this.

test: { },
lint: {
files: ['src/**/*.ts', 'src/**/*.tsx', 'tests/**/*', 'test/**/*.js']
files: [
'src/**/*.[jt]s',
'src/**/*.[jt]sx',
'test/**/*.[jt]s',
'test/**/*.[jt]sx',
'test-e2e/**/*.[jt]s'
]
},
dependencyCheck: {
ignore: [
Expand All @@ -20,7 +90,7 @@ export default {
productionIgnorePatterns: [
'webpack.config.js',
'.aegir.js',
'/tests',
'/test',
'dist'
]
}
Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,10 @@ $RECYCLE.BIN/

# End of https://www.toptal.com/developers/gitignore/api/macos,node,windows,linux
.vscode
dist-tsc
dist-esbuild
playwright-report
.envrc
.direnv
*.nix
.coverage
Expand Down
Loading
Loading