GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add example to copy files to public during build · HallexCosta/nullstack.github.io@c6e92d0

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • i18n
    • en-US
      • components
        • Examples.yml
      • examples
        • copying-static-files-to-the-public-folder-on-build.md
    • pt-BR
      • components
        • Examples.yml
      • examples
        • copiando-arquivos-estaticos-para-pasta-public-durante-o-build.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎i18n/en-US/components/Examples.yml‎

Copy file name to clipboardExpand all lines: i18n/en-US/components/Examples.yml
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,5 @@ posts:
3737
- title: "Using Nullstack to build a personal Portfolio on GitHub"
3838
href: "/examples/using-nullstack-to-build-a-personal-portfolio-on-github"
3939
description: "Nullstack can be used to build a personal Portfolio on GitHub."
40+
- title: "Copying static files to the public folder on build"
41+
href: "/examples/copying-static-files-to-the-public-folder-on-build"
Collapse file

‎i18n/en-US/examples/copying-static-files-to-the-public-folder-on-build.md‎

Copy file name to clipboard
+42Lines changed: 42 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
title: "Copying static files to the public folder on build"
3+
description: "Copy static files to the public folder, like schema files, css, js and other files that comes with certain packages"
4+
---
5+
6+
To copy static files to the public folder you need to create a custom webpack override.
7+
8+
In order to modify the webpack config that comes in the Nullstack bundle, you can create a `webpack.config.js` as mentioned in the documentation ["How to customize Webpack"](/how-to-customize-webpack).
9+
10+
```js
11+
// webpack.config.js
12+
const [server, client] = require("nullstack/webpack.config");
13+
14+
const fse = require("fs-extra");
15+
16+
class CopyFiles {
17+
apply() {
18+
fse.copySync("node_modules/swagger-ui-dist", "public/api-docs", {
19+
overwrite: true,
20+
});
21+
}
22+
}
23+
24+
function customServer(...args) {
25+
const config = server(...args);
26+
config.plugins.push(new CopyFiles());
27+
return config;
28+
}
29+
30+
module.exports = [customServer, client];
31+
```
32+
33+
In case you need to serve these files, you can use `context.server` to create a route and `express.static` to point to the files you want to serve.
34+
35+
```js
36+
// server.js
37+
context.server.use(
38+
"/api-docs/",
39+
express.static(path.join(__dirname, "..", "public/api-docs"))
40+
);
41+
// ...
42+
```
Collapse file

‎i18n/pt-BR/components/Examples.yml‎

Copy file name to clipboardExpand all lines: i18n/pt-BR/components/Examples.yml
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ posts:
1919
- title: "Using Nullstack to build a personal Portfolio on GitHub"
2020
href: "/examples/using-nullstack-to-build-a-personal-portfolio-on-github"
2121
description: "Nullstack can be used to build a personal Portfolio on GitHub."
22+
- title: "Copiando arquivos estaticos para pasta public durante o build"
23+
href: "/examples/copiando-arquivos-estaticos-para-pasta-public-durante-o-build"
Collapse file

‎i18n/pt-BR/examples/copiando-arquivos-estaticos-para-pasta-public-durante-o-build.md‎

Copy file name to clipboard
+42Lines changed: 42 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
title: "Copiando arquivos estaticos para pasta public durante o build"
3+
description: "Copiando arquivos estaticos para pasta public, como arquivos de schema, css, js e outros arquivos que vem com certos pacotes"
4+
---
5+
6+
To copy static files to the public folder you need to create a custom webpack override.
7+
8+
In order to modify the webpack config that comes in the Nullstack bundle, you can create a `webpack.config.js` as mentioned in the documentation ["How to customize Webpack"](/how-to-customize-webpack).
9+
10+
```js
11+
// webpack.config.js
12+
const [server, client] = require("nullstack/webpack.config");
13+
14+
const fse = require("fs-extra");
15+
16+
class CopyFiles {
17+
apply() {
18+
fse.copySync("node_modules/swagger-ui-dist", "public/api-docs", {
19+
overwrite: true,
20+
});
21+
}
22+
}
23+
24+
function customServer(...args) {
25+
const config = server(...args);
26+
config.plugins.push(new CopyFiles());
27+
return config;
28+
}
29+
30+
module.exports = [customServer, client];
31+
```
32+
33+
In case you need to serve these files, you can use `context.server` to create a route and `express.static` to point to the files you want to serve.
34+
35+
```js
36+
// server.js
37+
context.server.use(
38+
"/api-docs/",
39+
express.static(path.join(__dirname, "..", "public/api-docs"))
40+
);
41+
// ...
42+
```

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.