Can't render pug files using `electron-forge start`
See original GitHub issue- I have read the contribution documentation for this project.
- I agree to follow the code of conduct that this project follows, as appropriate.
- I have searched the issue tracker for an issue that matches the one I want to file, without success.
Please describe your issue:
Console output when you run electron-forge
with the environment variable DEBUG=electron-forge:*
. (Instructions on how to do so here). Please include the stack trace if one exists.
Put the console output here
What command line arguments are you passing?
Put the arguments here
What does your config.forge
data in package.json
look like?
Paste the config.forge JSON object here
"config": {
"forge": {
"make_targets": {
"win32": [
"squirrel"
],
"darwin": [
"zip"
],
"linux": [
"deb",
"rpm"
]
},
"electronPackagerConfig": {
"packageManager": "npm"
},
"electronWinstallerConfig": {
"name": "foo"
},
"electronInstallerDebian": {},
"electronInstallerRedhat": {},
"github_repository": {
"owner": "",
"name": ""
},
"windowsStoreConfig": {
"packageName": "",
"name": "foo"
}
}
Please provide either a failing minimal testcase (with a link to the code) or detailed steps to
reproduce your problem. Using electron-forge init
is a good starting point, if that is not the
source of your problem.
Hello I have created a simple app using electron-forge init
Until here if I run electron-forge start
the default app appears and everything is working fine.
However in my app I want to use pug
templates.To do this I have installed electron-pug
using npm install --save electron-pug
.
Here is the complete code of my default index.js
file after adding electron-pug
:
const { app, BrowserWindow } = require('electron');
const pug = require('electron-pug')({pretty:true},{});
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;
const createWindow = () => {
// Create the browser window.
mainWindow = new BrowserWindow({
width: 800,
height: 600,
});
// and load the index.html of the app.
mainWindow.loadURL(`file://${__dirname}/demo.pug`);
// Open the DevTools.
mainWindow.webContents.openDevTools();
// Emitted when the window is closed.
mainWindow.on('closed', () => {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});
};
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow);
// Quit when all windows are closed.
app.on('window-all-closed', () => {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) {
createWindow();
}
});
// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and import them here.
And here is the code for for demo.pug
file:
doctype
html
head
title Nope
body
h1 Hello
p
| Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
Now if I run npm start
which in turn calls electron-forge start
my pug file won’t render and it will log the following error in my console:
Pug interceptor failed: Error: The scheme has been intercepted
Here is a screenshot of my app when running npm start
"
However if I runelectron src/index.js
from the root of my project folder my pug file will be rendered producing the following output:
Any ideas how I can fix that.I really need to use electron-forge
in some projects which use electron-pug
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
You probably want to put that code in a block so formatting, etc. are preserved.
Using
electron-pug
should work 🆗 in Electron Forge 6.0.0 as we don’t enableelectron-compile
support by default. Docs will be up soon explaining how to use 6.0.0-beta.X and you should be able to pick those up 👍