Skip to content

Commit

Permalink
Copy preload from base to webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
malept committed Feb 12, 2022
1 parent d0beaac commit 27b2ec9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/template/webpack/test/WebpackTemplate_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ describe('WebpackTemplate', () => {
});

it('should copy the appropriate template files', async () => {
const expectedFiles = ['webpack.main.config.js', 'webpack.renderer.config.js', 'webpack.rules.js', path.join('src', 'renderer.js')];
const expectedFiles = [
'webpack.main.config.js',
'webpack.renderer.config.js',
'webpack.rules.js',
path.join('src', 'renderer.js'),
path.join('src', 'preload.js'),
];
for (const filename of expectedFiles) {
await testUtils.expectProjectPathExists(dir, filename, 'file');
}
Expand All @@ -25,7 +31,9 @@ describe('WebpackTemplate', () => {
it('should move and rewrite the main process file', async () => {
await testUtils.expectProjectPathNotExists(dir, path.join('src', 'index.js'), 'file');
await testUtils.expectProjectPathExists(dir, path.join('src', 'main.js'), 'file');
expect((await fs.readFile(path.join(dir, 'src', 'main.js'))).toString()).to.match(/MAIN_WINDOW_WEBPACK_ENTRY/);
const mainFile = (await fs.readFile(path.join(dir, 'src', 'main.js'))).toString();
expect(mainFile).to.match(/MAIN_WINDOW_WEBPACK_ENTRY/);
expect(mainFile).to.match(/MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY/);
});

it('should remove the stylesheet link from the HTML file', async () => {
Expand Down
2 changes: 2 additions & 0 deletions packages/template/webpack/tmpl/preload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// See the Electron documentation for details on how to use preload scripts:
// https://www.electronjs.org/docs/latest/tutorial/process-model#preload-scripts

0 comments on commit 27b2ec9

Please sign in to comment.