Skip to content
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

Can't render pug files using electron-forge start #291

Closed
3 tasks done
kounelios13 opened this issue Aug 10, 2017 · 6 comments
Closed
3 tasks done

Can't render pug files using electron-forge start #291

kounelios13 opened this issue Aug 10, 2017 · 6 comments

Comments

@kounelios13
Copy link

kounelios13 commented Aug 10, 2017

  • 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.

screenshot from 2017-08-11 00 09 37

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"
screenshot from 2017-08-11 00 20 54

However if I runelectron src/index.js from the root of my project folder my pug file will be rendered producing the following output:

screenshot from 2017-08-11 00 22 55

Any ideas how I can fix that.I really need to use electron-forge in some projects which use electron-pug

@malept
Copy link
Member

malept commented Aug 10, 2017

And here is the code for for demo.pug file

You probably want to put that code in a block so formatting, etc. are preserved.

@kounelios13
Copy link
Author

@malept sorry for this.Now it is fixed

@malept
Copy link
Member

malept commented Aug 10, 2017

I think it's because both electron-compile (a dependency of Forge) and electron-pug both intercept the file protocol.

@kounelios13
Copy link
Author

It there anything I can do about that?

@malept
Copy link
Member

malept commented Aug 11, 2017

You could try to use electron-userland/electron-compilers#66 plus electron-userland/electron-compile#215 and see if they work. (Put the electron-compilers branch in your devDependencies. You also would need to remove electron-pug.)

@MarshallOfSound
Copy link
Member

Using electron-pug should work 🆗 in Electron Forge 6.0.0 as we don't enable electron-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 👍

dsanders11 pushed a commit that referenced this issue Jan 14, 2023
chore: Update various dependencies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants