Skip to content

Commit 0755f79

Browse files
committed
Split dist/ to individual subdirectories
1 parent 3448088 commit 0755f79

10 files changed

Lines changed: 30 additions & 23 deletions

File tree

docs-developer/deploying.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
Our hosting service is [Netlify](https://www.netlify.com/). Deploying on a nginx instance is also possible, see below.
44

5+
The repository config sets Netlify's publish directory to `dist/browser` in
6+
[`netlify.toml`](/netlify.toml).
7+
58
## Deploy to production
69

710
The `production` branch is configured to be automatically deployed to
@@ -94,6 +97,6 @@ document](https://docs.google.com/document/d/16YRafdIbk4aFgu4EZjMEjX4F6jIcUJQsaz
9497
# Deploying on a nginx instance
9598

9699
To deploy on nginx (without support for direct upload from the Firefox UI), run `yarn build-prod`
97-
and point nginx at the `dist` directory, which needs to be at the root of the webserver. Additionally,
100+
and point nginx at the `dist/browser` directory, which needs to be at the root of the webserver. Additionally,
98101
a `error_page 404 =200 /index.html;` directive needs to be added so that unknown URLs respond with index.html.
99102
For a more production-ready configuration, have a look at the netlify [`_headers`](/res/_headers) file.

netlify.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1+
[build]
2+
publish = "dist/browser"
3+
14
[context.l10n]
25
command = "yarn build-l10n-prod"

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
"protoc": "npx -p protobufjs-cli pbjs -t static-module -w commonjs -o ./src/profile-logic/import/proto/simpleperf_report.js ./src/profile-logic/import/proto/simpleperf_report.proto && npx -p protobufjs-cli pbts -o ./src/profile-logic/import/proto/simpleperf_report.d.ts ./src/profile-logic/import/proto/simpleperf_report.js",
3535
"license-check": "devtools-license-check",
3636
"preinstall": "node bin/pre-install.js",
37-
"publish": "rimraf public_html && cp -r dist public_html",
38-
"serve-static": "ws -d dist/ -s index.html -p 4243",
37+
"publish": "rimraf public_html && cp -r dist/browser public_html",
38+
"serve-static": "ws -d dist/browser/ -s index.html -p 4243",
3939
"start": "cross-env NODE_ENV=development node scripts/run-dev-server.mjs",
4040
"start-prod": "yarn build-prod && yarn serve-static",
4141
"start-l10n": "cross-env NODE_ENV=development L10N=1 node scripts/run-dev-server.mjs",

scripts/build-symbolicator.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const symbolicatorConfig = {
88
...nodeBaseConfig,
99
metafile: true,
1010
entryPoints: ['src/symbolicator-cli/index.ts'],
11-
outfile: 'dist/symbolicator-cli.js',
11+
outfile: 'dist/node-tools/symbolicator-cli.js',
1212
};
1313

1414
async function build() {

scripts/build.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { mainBundleConfig } from './lib/esbuild-configs.mjs';
77
import { cleanDist, saveMetafile } from './lib/build-utils.mjs';
88

99
async function build() {
10-
cleanDist();
10+
cleanDist('dist/browser');
1111
const buildResult = await esbuild.build(mainBundleConfig);
1212
saveMetafile(buildResult);
1313
console.log('✅ Main browser build completed');

scripts/lib/esbuild-configs.mjs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const __dirname = path.dirname(__filename);
1919
const projectRoot = path.normalize(path.join(__dirname, '..', '..'));
2020

2121
const isProduction = process.env.NODE_ENV === 'production';
22+
const browserDistDir = 'dist/browser';
2223

2324
// Configuration shared by both node and browser builds
2425
const baseConfig = {
@@ -68,7 +69,7 @@ export const mainBundleConfig = {
6869
sourcemap: true,
6970
splitting: true,
7071
entryPoints: ['src/index.tsx'],
71-
outdir: 'dist',
72+
outdir: browserDistDir,
7273
metafile: true,
7374
publicPath: '/',
7475
entryNames: '[name]-[hash]',
@@ -90,14 +91,14 @@ export const mainBundleConfig = {
9091
copy({
9192
resolveFrom: projectRoot,
9293
assets: [
93-
{ from: ['res/_headers'], to: ['dist'] },
94-
{ from: ['res/_redirects'], to: ['dist'] },
95-
{ from: ['res/contribute.json'], to: ['dist'] },
96-
{ from: ['res/robots.txt'], to: ['dist'] },
97-
{ from: ['res/service-worker-compat.js'], to: ['dist'] },
98-
{ from: ['res/img/favicon.png'], to: ['dist/res/img'] },
99-
{ from: ['docs-user/**/*'], to: ['dist/docs'] },
100-
{ from: ['locales/**/*'], to: ['dist/locales'] },
94+
{ from: ['res/_headers'], to: [browserDistDir] },
95+
{ from: ['res/_redirects'], to: [browserDistDir] },
96+
{ from: ['res/contribute.json'], to: [browserDistDir] },
97+
{ from: ['res/robots.txt'], to: [browserDistDir] },
98+
{ from: ['res/service-worker-compat.js'], to: [browserDistDir] },
99+
{ from: ['res/img/favicon.png'], to: [`${browserDistDir}/res/img`] },
100+
{ from: ['docs-user/**/*'], to: [`${browserDistDir}/docs`] },
101+
{ from: ['locales/**/*'], to: [`${browserDistDir}/locales`] },
101102
],
102103
}),
103104
generateHtmlPlugin({
@@ -122,7 +123,7 @@ export const photonConfig = {
122123
sourcemap: true,
123124
publicPath: '/photon/',
124125
entryPoints: ['res/photon/index.js'],
125-
outdir: 'dist/photon',
126+
outdir: `${browserDistDir}/photon`,
126127
metafile: true,
127128
plugins: [
128129
generateHtmlPlugin({

scripts/run-dev-server.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const argv = yargs(hideBin(process.argv))
2020
startDevServer(mainBundleConfig, {
2121
port,
2222
host,
23-
distDir: 'dist',
23+
distDir: 'dist/browser',
2424
cleanDist: true,
2525
onServerStart: (profilerUrl) => {
2626
const barAscii =

scripts/run-photon-dev-server.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ const host = process.env.FX_PROFILER_PHOTON_HOST || 'localhost';
1010
startDevServer(photonConfig, {
1111
port,
1212
host,
13-
distDir: 'dist',
13+
distDir: 'dist/browser',
1414
fallback: 'photon/index.html',
15-
cleanDist: false, // Don't clean the whole dist, just photon
15+
cleanDist: false, // Don't clean the whole dist/browser, just photon
1616
onServerStart: (url) => {
1717
console.log(`> Photon styling is listening at: ${url}/photon/\n`);
1818
},

src/symbolicator-cli/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
* To use it it first needs to be built:
66
* yarn build-symbolicator-cli
77
*
8-
* Then it can be run from the `dist` directory:
9-
* node dist/symbolicator-cli.js --input <input profile> --output <symbolicated profile> --server <symbol server URL>
8+
* Then it can be run from the `dist/node-tools` directory:
9+
* node dist/node-tools/symbolicator-cli.js --input <input profile> --output <symbolicated profile> --server <symbol server URL>
1010
*
1111
* For example:
12-
* node dist/symbolicator-cli.js --input samply-profile.json --output profile-symbolicated.json --server http://localhost:3000
12+
* node dist/node-tools/symbolicator-cli.js --input samply-profile.json --output profile-symbolicated.json --server http://localhost:3000
1313
*
1414
*/
1515

workbox-config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ module.exports = {
3737
// convenient that we can just access it from a browser.
3838
/^\/sw\.js/,
3939
],
40-
globDirectory: 'dist',
40+
globDirectory: 'dist/browser',
4141
globPatterns: ['**/*'],
4242
globIgnores: [
4343
// exclude user docs and photon from the cache
@@ -55,5 +55,5 @@ module.exports = {
5555
// This is the service worker file name. It should never change if we want
5656
// that the browser updates it. If this changes it will never be updated
5757
// and the user will be stuck with an old version.
58-
swDest: 'dist/sw.js',
58+
swDest: 'dist/browser/sw.js',
5959
};

0 commit comments

Comments
 (0)