Git Product home page Git Product logo

Comments (2)

manidlou avatar manidlou commented on June 13, 2024 1

@richardtape you are right. elemon is a tool that you need it only in development. Essentially, in order to achieve what you want, I can think of 3 ways at this moment. Methods 2 and 3 require to use electron-is-dev.

  1. Have 2 different package.json files. This refers to two package.json structure.
  2. elemon uses electron-is-dev internally. Then, users install it like npm i elemon --save. This means users don't need to guard it for production. However, I don't like this because elemon has a dependency (chokidar) and it means all these dependency modules will be bundled in your final app while you don't need them.
  3. Users (like you) use electron-is-dev and use elemon like the following example. I believe this is better since electron-is-dev is just 2 lines of code and doesn't have any dependencies. So, it basically doesn't hurt to be included in your final app in terms of size and other stuff.

So, you can do something like this:
npm i electron-is-dev --save
npm i elemon --save-dev

const {app, BrowserWindow} = require('electron')
const isDev = require('electron-is-dev')

function createWindows () {
  // ...
}

app.on('ready', () => {
  createWindows()

  if (isDev) {
    const elemon = require('elemon') // require elemon if electron is in dev
    elemon({
      app: app,
      mainFile: 'main.js',
      bws: [
        {bw: win1, res: ['win1.html', 'win1.js', 'style.css']},
        {bw: win2, res: ['win2.html', 'win2.js', 'style.css']}
      ]
    })
  }
})

Hopefully this helps you in your issue. Please let us know if you need further assistance.

from elemon.

manidlou avatar manidlou commented on June 13, 2024

This feature is documented now. Please reopen if needed.

from elemon.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.