Skip to content

Commit d6fd760

Browse files
harshitkumar31ForsakenHarmony
authored andcommitted
Copy static to root folder with build preactjs#865 (preactjs#866)
1 parent 07780a2 commit d6fd760

File tree

5 files changed

+24
-0
lines changed

5 files changed

+24
-0
lines changed

packages/cli/lib/lib/webpack/webpack-client-config.js

+5
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ async function clientConfig(env) {
109109
from: resolve(__dirname, '../../resources/sw-debug.js'),
110110
to: 'sw-debug.js',
111111
},
112+
// copy files from static to build directory
113+
existsSync(source('static')) && {
114+
from: resolve(source('static')),
115+
to: '.',
116+
},
112117
].filter(Boolean)
113118
),
114119
],

packages/cli/tests/build.test.js

+8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const { readFile } = require('../lib/fs');
33
const looksLike = require('html-looks-like');
44
const { create, build } = require('./lib/cli');
55
const { snapshot, isMatch } = require('./lib/utils');
6+
const { existsSync } = require('fs');
67
const { subject } = require('./lib/output');
78
const images = require('./images/build');
89

@@ -136,4 +137,11 @@ describe('preact build', () => {
136137
let dir = await subject('location-patch');
137138
expect(() => build(dir)).not.toThrow();
138139
});
140+
141+
it('should copy resources from static to build directory', async () => {
142+
let dir = await subject('static-root');
143+
await build(dir);
144+
let file = join(dir, 'build', '.htaccess');
145+
expect(existsSync(file)).toBe(true);
146+
});
139147
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { h } from 'preact';
2+
3+
export default () => {
4+
return <h1>Static test</h1>;
5+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"private": true,
3+
"name": "preact-prerender"
4+
}
5+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# dummy to check

0 commit comments

Comments
 (0)