electron-userland/electron-compile — dự án mã nguồn mở — đang có 994 sao GitHub. DEPRECATED: Electron supporting package to compile JS and CSS in Electron applications
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
Create a new file that will be the entry point of your app (perhaps changing 'main' in package.json) - you need to pass in the root directory of your application, which will vary based on your setup. The root directory is the directory that your package.json is in.
// Assuming this file is ./src/es6-init.js
var appRoot = path.join(__dirname, '..');
require('electron-compile').init(appRoot, require.resolve('./main'));
I did it, now what?
From then on, you can now simply include files directly in your HTML, no need for cross-compilation:
In your main file, before you create a BrowserWindow instance:
import {enableLiveReload} from 'electron-compile';
enableLiveReload();
React Hot Module Loading
If you are using React, you can also enable Hot Module Reloading for both JavaScript JSX files as well as TypeScript, with a bit of setup:
npm install --save react-hot-loader@next
Call enableLiveReload({strategy: 'react-hmr'}); in your main file, after app.ready (similar to above)
If you're using TypeScript, you're good out-of-the-box. If you're using JavaScript via Babel, add 'react-hot-loader/babel' to your plugins in .compilerc:
In your index.html, replace your initial call to render:
Typical code without React HMR:
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { MyApp } from './my-app';
ReactDOM.render(<MyApp/>, document.getElementById('app'));
Rewrite this as:
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { AppContainer } from 'react-hot-loader';
const render = () => {
// NB: We have to re-require MyApp every time or else this won't work
// We also need to wrap our app in the AppContainer class
const MyApp = require('./myapp').MyApp;
ReactDOM.render(<AppContainer><MyApp/></AppContainer>, document.getElementById('app'));
}
render();
if (module.hot) { module.hot.accept(render); }
Something isn't working / I'm getting weird errors
electron-compile uses the debug module, set the DEBUG environment variable to debug what electron-compile is doing:
## Debug just electron-compile
DEBUG=electron-compile:* npm start
## Grab everything except for Babel which is very noisy
DEBUG=*,-babel npm start
How do I set up (Babel / Less / whatever) the way I want?
If you've got a .babelrc and that's all you want to customize, you can simply use it directly. electron-compile will respect it, even the environment-specific settings. If you want to customize other compilers, use a .compilerc or .compilerc.json file. Here's an example:
By far, the easiest way to do this is via using electron-forge. electron-forge handles every aspect of packaging your app on all platforms and helping you publish it. Unless you have a very good reason, you should be using it!
How can I precompile my code for release-time? (the hard way)
electron-compile comes with a command-line application to pre-create a cache for you.
Usage: electron-compile --appdir [root-app-dir] paths...
Options:
-a, --appdir The top-level application directory (i.e. where your
package.json is)
-v, --verbose Print verbose information
-h, --help Show help
Run electron-compile on all of your application assets, even if they aren't strictly code (i.e. your static assets like PNGs). electron-compile will recursively walk the given directories.
Đọc thêm về electron-userland/electron-compile ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/electron-userland/electron-compile là nguồn chính thức.
electron-userland/electron-compile có phải mã nguồn mở không?
TopGit chưa ghi nhận license cho electron-userland/electron-compile. Phần lớn repo public trên GitHub là mã nguồn mở, nhưng điều khoản khác nhau từng repo — mở file LICENSE để xác nhận.
electron-userland/electron-compile có website riêng không?
TopGit chưa ghi nhận URL trang chủ cho electron-userland/electron-compile. Phần README ở tab phía trên thường có link demo, hoặc xem mô tả GitHub của repo.
electron-userland/electron-compile là gì?
electron-userland/electron-compile (electron-userland/electron-compile) là dự án JavaScript trên GitHub. Theo mô tả gốc: DEPRECATED: Electron supporting package to compile JS and CSS in Electron applications
Đọc đầy đủ README ở tab phía trên.
Vẫn đang phân vân về electron-compile?
Một cú bấm sẽ gửi câu hỏi kèm trang này cho AI — xem AI nói gì về electron-compile.