question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Migration to use `electron-webpack`

See original GitHub issue

Hi. First of all, thanks for excellent boilerplate.

Because it was clear, that electron-compile and electron-forge template for vue is definitely not a way to develop Vue application, I started to use this boilerplate.

But we can make it better and fix some current issues.

  1. HMR doesn’t work. Hot reload works, but… it is not productive. I want to just change my vue component and see result without reload.
  2. TypeScript support.
  3. Minor — easy update boilerplate and get rid of boilerplate files in the project.

I have fixed these issues in the https://github.com/electron-userland/electron-webpack. This new project is not called as electron-vue-scripts (as was planned initially), because, actually, in this boilerplate nothing specific for Vue and nothing prevents us to reuse boilerplate for any Electron application for any framework (or mix frameworks).

  1. HMR — issue is that some loaders cannot detect hot reload mode if webpack-dev-server is running not as CLI. e.g. https://github.com/elm-community/elm-webpack-loader/issues/98 And I can confirm, that vue-loader also doesn’t support HMR in this case. Yes — we can fight and investigate/fix/apply special configuration for each used loader, but it is maintenance hell. Actually, nothing prevent us to run webpack-dev-server using CLI and even more — we should, because it helps to compile faster (for the same reason why https://github.com/trivago/parallel-webpack was developed). So, CLI is used instead of programmatic usage in the electron-webpack.

    Now HMR works. And even more — there is a simple way to add HMR support for main process (mostly done on electron-webpack configuration side, but not documented/tested/helper script not provided).

  2. Way “select option during project creation” is not flexible, because what if I want to add some feature later? For what we need to complicate things, if we simply can provide some preset and detect it? Or just detect loaders (check project dependencies and devDependencies) and automatically apply corresponding configuration.

    So, two presets is implemented: electron-webpack-ts and electron-webpack-vue. These presets are nothing more than just list of dependencies (so, user don’t need to list all required, because, for example, for vue we need to add 4 dependencies). electron-webpack can work without these presets, i.e. ts-loader can be installed explicitly and it will be detected.

    For example, vue support is automatically configured if vue in the project dependency.

  3. Webpack is amazing. Multiple async configs are supported. No need to reinvent the wheel. Do you want to compile the whole app — that’s easy, just pass special configuration file: webpack --env.production --progress --bail --config node_modules/electron-webpack/webpack.app.config.js

    Here webpack.app.config.js is just a collection of renderer and main configs. No special script — all power of webpack in your hands and you are not limited. No boundaries are set by electron-webpack and you can use provided configuration files in a various scenarios (e.g. do not use yarn dev script, but run separately for better IDE support).

    And if user want, parallel-webpack can be also used. Maybe later we will provide special compile script but I doubt. electron-builder will support webpack configs soon and it will work better than any user solution / not electron-builder solution, because in-memory compilation will be used.

What do I suggest: change this boilerplate to use electron-webpack.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:12
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

8reactions
SimulatedGREGcommented, Oct 5, 2017

For those that are interested with electron-webpack, there has been a lot of hard work done between me and mostly @develar to get everything stable and I’m happy to announce the first draft for electron-vue is out now. It currently only supports using electron-builder and doesn’t have any testing support as of yet. The overall plan is to keep all current features that electron-vue provides, and avoid major changes.

You can try it out now with the feat/electron-webpack branch.

vue init simulatedgreg/electron-vue#feat/electron-webpack my-project

Please let me know what issues you guys may run into and post them here.

7reactions
DrSensorcommented, Oct 17, 2017

Can you also share the step for migrating existing project to use electron-webpack?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Looking for maintainers! Or use Vite to develop your ...
We are finding for active maintainers who can look after PRs, issues and publising to npm. As the electron has a lot of...
Read more >
Getting Started with Electron, Typescript, React and Webpack
Explore our approach to setting up Electron using a major front-end framework. Start with a basic Electron project then configure it to use...
Read more >
electron-webpack
The primary aim of electron-webpack is to eliminate all preliminary setup with one simple install so you can get back to developing your...
Read more >
Introducing Electron Forge 6
Easy-to-use boilerplate templates for webpack and TypeScript ... Electron Builder, or Forge 5), it will try to migrate as many settings as ...
Read more >
To v5 from v4
This guide aims to help you migrating to webpack 5 when using webpack directly. If you are using a higher level tool to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found