Skip to content

Copy static/root to root folder with build #865 #866

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

Merged
merged 4 commits into from
Aug 11, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions packages/cli/lib/lib/webpack/webpack-client-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ async function clientConfig(env) {
from: resolve(__dirname, '../../resources/sw-debug.js'),
to: 'sw-debug.js',
},
// copy files from static to build directory
existsSync(source('static')) && {
from: resolve(source('static')),
to: '.',
},
].filter(Boolean)
),
],
Expand Down
8 changes: 8 additions & 0 deletions packages/cli/tests/build.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const { readFile } = require('../lib/fs');
const looksLike = require('html-looks-like');
const { create, build } = require('./lib/cli');
const { snapshot, isMatch } = require('./lib/utils');
const { existsSync } = require('fs');
const { subject } = require('./lib/output');
const images = require('./images/build');

Expand Down Expand Up @@ -136,4 +137,11 @@ describe('preact build', () => {
let dir = await subject('location-patch');
expect(() => build(dir)).not.toThrow();
});

it('should copy resources from static to build directory', async () => {
let dir = await subject('static-root');
await build(dir);
let file = join(dir, 'build', '.htaccess');
expect(existsSync(file)).toBe(true);
});
});
5 changes: 5 additions & 0 deletions packages/cli/tests/subjects/static-root/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { h } from 'preact';

export default () => {
return <h1>Static test</h1>;
};
5 changes: 5 additions & 0 deletions packages/cli/tests/subjects/static-root/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"private": true,
"name": "preact-prerender"
}

1 change: 1 addition & 0 deletions packages/cli/tests/subjects/static-root/static/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# dummy to check