Electron 如何缩小电子应用程序的大小?
我开始学习Electron,我下载了入门示例项目,它的时钟大约为150MBElectron 如何缩小电子应用程序的大小?,electron,electron-packager,Electron,Electron Packager,我开始学习Electron,我下载了入门示例项目,它的时钟大约为150MB 电子项目的基本要素是什么?我可以删除节点\模块文件夹吗?我最终需要调用一个进程,但仅此而已 使用webpack,只提供应用程序所需的依赖项。 另外,使用copy webpack plugin复制您需要的文件,这些文件不是通过webpack捆绑的 不要运送整个节点模块文件夹 示例网页包配置- const path = require('path'); var CopyWebpackPlugin = requ
电子项目的基本要素是什么?我可以删除节点\模块文件夹吗?我最终需要调用一个进程,但仅此而已 使用webpack,只提供应用程序所需的依赖项。 另外,使用
copy webpack plugin
复制您需要的文件,这些文件不是通过webpack捆绑的
不要运送整个节点模块
文件夹
示例网页包配置-
const path = require('path');
var CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
entry: {
main: './main.ts',
renderer: './src/renderer.js',
},
devtool: 'inline-source-map',
output: {
filename: "[name].js",
path: path.resolve(__dirname, 'public')
},
resolve: {
extensions: [".tsx", ".ts", ".js"]
},
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: ["es2015", "react"]
}
}
},
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/
}
]
},
target: "electron-main",
bail: true,
node: {
__dirname: false,
__filename: false
},
plugins: [
new CopyWebpackPlugin([
{ from: './index.html' }
])
]
};
因此,上面创建了一个
public
文件夹,这是您的最终捆绑输出。使用webpack,只提供应用程序所需的依赖项。
另外,使用copy webpack plugin
复制您需要的文件,这些文件不是通过webpack捆绑的
不要运送整个节点模块
文件夹
示例网页包配置-
const path = require('path');
var CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
entry: {
main: './main.ts',
renderer: './src/renderer.js',
},
devtool: 'inline-source-map',
output: {
filename: "[name].js",
path: path.resolve(__dirname, 'public')
},
resolve: {
extensions: [".tsx", ".ts", ".js"]
},
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: ["es2015", "react"]
}
}
},
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/
}
]
},
target: "electron-main",
bail: true,
node: {
__dirname: false,
__filename: false
},
plugins: [
new CopyWebpackPlugin([
{ from: './index.html' }
])
]
};
因此,上面创建了一个public
文件夹,这是您的最终捆绑输出