mirror of
https://github.com/bitwarden/desktop.git
synced 2024-11-30 12:54:31 +01:00
pack main and renderer
This commit is contained in:
parent
0a803958e9
commit
268ec9960e
13
package.json
13
package.json
@ -3,12 +3,12 @@
|
|||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "webpack --config webpack.dev.js",
|
|
||||||
"dev:watch": "webpack --config webpack.dev.js --watch",
|
|
||||||
"lint": "tslint src/**/*.ts || true",
|
"lint": "tslint src/**/*.ts || true",
|
||||||
"lint:fix": "tslint src/**/*.ts --fix",
|
"lint:fix": "tslint src/**/*.ts --fix",
|
||||||
"server": "webpack-dev-server --inline --progress --port 8080 --config webpack.dev.js",
|
"build:main": "webpack --config webpack.main.js",
|
||||||
"electron": "tsc src/main.ts --outDir build && (electron ./build --dev --watch | npm run dev:watch)"
|
"build:renderer": "webpack --config webpack.renderer.js",
|
||||||
|
"build:renderer:watch": "webpack --config webpack.renderer.js --watch",
|
||||||
|
"electron": "(npm run build:main | npm run build:renderer) & (electron ./build --dev --watch | npm run build:renderer:watch)"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@bitwarden/jslib": "git+https://github.com/bitwarden/jslib.git",
|
"@bitwarden/jslib": "git+https://github.com/bitwarden/jslib.git",
|
||||||
@ -30,14 +30,13 @@
|
|||||||
"node-loader": "^0.6.0",
|
"node-loader": "^0.6.0",
|
||||||
"node-sass": "^4.7.2",
|
"node-sass": "^4.7.2",
|
||||||
"sass-loader": "^6.0.6",
|
"sass-loader": "^6.0.6",
|
||||||
"style-loader": "^0.19.0",
|
|
||||||
"ts-loader": "^3.0.5",
|
"ts-loader": "^3.0.5",
|
||||||
"tslint": "^5.8.0",
|
"tslint": "^5.8.0",
|
||||||
"tslint-loader": "^3.5.3",
|
"tslint-loader": "^3.5.3",
|
||||||
"typescript": "^2.5.3",
|
"typescript": "^2.5.3",
|
||||||
"webpack": "^3.8.1",
|
"webpack": "^3.8.1",
|
||||||
"webpack-dev-server": "^2.11.0",
|
"webpack-merge": "^4.1.0",
|
||||||
"webpack-merge": "^4.1.0"
|
"webpack-node-externals": "^1.6.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/animations": "5.2.0",
|
"@angular/animations": "5.2.0",
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
|
//import { remote } from 'electron';
|
||||||
|
|
||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
|
|
||||||
import { DesktopMessagingService } from './desktopMessaging.service';
|
import { DesktopMessagingService } from '../../services/desktopMessaging.service';
|
||||||
import { DesktopPlatformUtilsService } from './desktopPlatformUtils.service';
|
import { DesktopPlatformUtilsService } from '../../services/desktopPlatformUtils.service';
|
||||||
import { DesktopStorageService } from './desktopStorage.service';
|
import { DesktopStorageService } from '../../services/desktopStorage.service';
|
||||||
import { DesktopSecureStorageService } from './desktopSecureStorage.service';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ApiService,
|
ApiService,
|
||||||
@ -52,7 +53,7 @@ const utilsService = new UtilsService();
|
|||||||
const platformUtilsService = new DesktopPlatformUtilsService();
|
const platformUtilsService = new DesktopPlatformUtilsService();
|
||||||
const messagingService = new DesktopMessagingService();
|
const messagingService = new DesktopMessagingService();
|
||||||
const storageService: StorageServiceAbstraction = new DesktopStorageService();
|
const storageService: StorageServiceAbstraction = new DesktopStorageService();
|
||||||
//const secureStorageService: StorageServiceAbstraction = new DesktopSecureStorageService();
|
const secureStorageService: StorageServiceAbstraction = storageService; //remote.getGlobal('secureStorageService');
|
||||||
const constantsService = new ConstantsService({}, 0);
|
const constantsService = new ConstantsService({}, 0);
|
||||||
const cryptoService = new CryptoService(storageService, storageService);
|
const cryptoService = new CryptoService(storageService, storageService);
|
||||||
const tokenService = new TokenService(storageService);
|
const tokenService = new TokenService(storageService);
|
||||||
|
@ -2,6 +2,10 @@ import { app, BrowserWindow, screen } from 'electron';
|
|||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as url from 'url';
|
import * as url from 'url';
|
||||||
|
|
||||||
|
//import { DesktopSecureStorageService } from './services/desktopSecureStorage.service';
|
||||||
|
//const secureStorageService = new DesktopSecureStorageService();
|
||||||
|
//(global as any).secureStorageService = secureStorageService;
|
||||||
|
|
||||||
let win: BrowserWindow;
|
let win: BrowserWindow;
|
||||||
const args = process.argv.slice(1);
|
const args = process.argv.slice(1);
|
||||||
const watch = args.some((val) => val === '--watch');
|
const watch = args.some((val) => val === '--watch');
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
import { Injectable } from '@angular/core';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
MessagingService,
|
MessagingService,
|
||||||
PlatformUtilsService,
|
PlatformUtilsService,
|
||||||
} from 'jslib/abstractions';
|
} from 'jslib/abstractions';
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class DesktopMessagingService implements MessagingService {
|
export class DesktopMessagingService implements MessagingService {
|
||||||
send(subscriber: string, arg: any = {}) {
|
send(subscriber: string, arg: any = {}) {
|
||||||
const message = Object.assign({}, { command: subscriber }, arg);
|
const message = Object.assign({}, { command: subscriber }, arg);
|
@ -1,5 +1,3 @@
|
|||||||
import { Injectable } from '@angular/core';
|
|
||||||
|
|
||||||
import { DeviceType } from 'jslib/enums';
|
import { DeviceType } from 'jslib/enums';
|
||||||
|
|
||||||
import { PlatformUtilsService } from 'jslib/abstractions';
|
import { PlatformUtilsService } from 'jslib/abstractions';
|
||||||
@ -10,7 +8,6 @@ const AnalyticsIds = {
|
|||||||
[DeviceType.MacOs]: 'UA-81915606-18',
|
[DeviceType.MacOs]: 'UA-81915606-18',
|
||||||
};
|
};
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class DesktopPlatformUtilsService implements PlatformUtilsService {
|
export class DesktopPlatformUtilsService implements PlatformUtilsService {
|
||||||
private deviceCache: DeviceType = null;
|
private deviceCache: DeviceType = null;
|
||||||
private analyticsIdCache: string = null;
|
private analyticsIdCache: string = null;
|
@ -1,9 +1,7 @@
|
|||||||
import { Injectable } from '@angular/core';
|
|
||||||
import { getPassword, setPassword, deletePassword } from 'keytar';
|
import { getPassword, setPassword, deletePassword } from 'keytar';
|
||||||
|
|
||||||
import { StorageService } from 'jslib/abstractions';
|
import { StorageService } from 'jslib/abstractions';
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class DesktopSecureStorageService implements StorageService {
|
export class DesktopSecureStorageService implements StorageService {
|
||||||
async get<T>(key: string): Promise<T> {
|
async get<T>(key: string): Promise<T> {
|
||||||
const val: string = await getPassword('bitwarden', key);
|
const val: string = await getPassword('bitwarden', key);
|
@ -1,11 +1,8 @@
|
|||||||
import { Injectable } from '@angular/core';
|
|
||||||
|
|
||||||
import { StorageService } from 'jslib/abstractions';
|
import { StorageService } from 'jslib/abstractions';
|
||||||
|
|
||||||
const Store = require('electron-store');
|
const Store = require('electron-store');
|
||||||
const store = new Store();
|
const store = new Store();
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class DesktopStorageService implements StorageService {
|
export class DesktopStorageService implements StorageService {
|
||||||
get<T>(key: string): Promise<T> {
|
get<T>(key: string): Promise<T> {
|
||||||
const val = store.get(key) as T;
|
const val = store.get(key) as T;
|
@ -1,24 +0,0 @@
|
|||||||
const merge = require('webpack-merge');
|
|
||||||
const common = require('./webpack.common.js');
|
|
||||||
|
|
||||||
module.exports = merge(common, {
|
|
||||||
devtool: 'inline-source-map',
|
|
||||||
module: {
|
|
||||||
rules: [
|
|
||||||
{
|
|
||||||
test: /\.scss$/,
|
|
||||||
use: [
|
|
||||||
{
|
|
||||||
loader: 'style-loader'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
loader: 'css-loader',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
loader: 'sass-loader',
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
});
|
|
64
webpack.main.js
Normal file
64
webpack.main.js
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
const path = require('path');
|
||||||
|
const webpack = require('webpack');
|
||||||
|
const merge = require('webpack-merge');
|
||||||
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
||||||
|
const CleanWebpackPlugin = require('clean-webpack-plugin');
|
||||||
|
const nodeExternals = require('webpack-node-externals');
|
||||||
|
|
||||||
|
const common = {
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.ts$/,
|
||||||
|
enforce: 'pre',
|
||||||
|
loader: 'tslint-loader'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.tsx?$/,
|
||||||
|
use: 'ts-loader',
|
||||||
|
exclude: /node_modules\/(?!(@bitwarden)\/).*/
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
plugins: [],
|
||||||
|
resolve: {
|
||||||
|
extensions: ['.tsx', '.ts', '.js'],
|
||||||
|
alias: {
|
||||||
|
jslib: path.join(__dirname, 'node_modules/@bitwarden/jslib/src')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
filename: '[name].js',
|
||||||
|
path: path.resolve(__dirname, 'build')
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const main = {
|
||||||
|
target: 'electron-main',
|
||||||
|
node: {
|
||||||
|
__dirname: false,
|
||||||
|
__filename: false
|
||||||
|
},
|
||||||
|
entry: {
|
||||||
|
'main': './src/main.ts'
|
||||||
|
},
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.node$/,
|
||||||
|
loader: 'node-loader'
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
new CleanWebpackPlugin([
|
||||||
|
path.resolve(__dirname, 'build/*')
|
||||||
|
]),
|
||||||
|
new CopyWebpackPlugin([
|
||||||
|
'./src/package.json',
|
||||||
|
]),
|
||||||
|
],
|
||||||
|
externals: [nodeExternals()]
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = merge(common, main);
|
@ -1,9 +1,9 @@
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const webpack = require('webpack');
|
const webpack = require('webpack');
|
||||||
const CleanWebpackPlugin = require('clean-webpack-plugin');
|
const merge = require('webpack-merge');
|
||||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||||
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
||||||
const GoogleFontsPlugin = require("google-fonts-webpack-plugin");
|
const GoogleFontsPlugin = require("google-fonts-webpack-plugin");
|
||||||
|
const ExtractTextPlugin = require('extract-text-webpack-plugin');
|
||||||
|
|
||||||
const isVendorModule = (module) => {
|
const isVendorModule = (module) => {
|
||||||
if (!module.context) {
|
if (!module.context) {
|
||||||
@ -15,17 +15,13 @@ const isVendorModule = (module) => {
|
|||||||
return nodeModule && !bitwardenModule;
|
return nodeModule && !bitwardenModule;
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
const extractCss = new ExtractTextPlugin({
|
||||||
target: 'electron-renderer',
|
filename: '[name].css',
|
||||||
devServer: {
|
disable: false,
|
||||||
contentBase: './src',
|
allChunks: true
|
||||||
historyApiFallback: true,
|
});
|
||||||
quiet: true,
|
|
||||||
stats: 'minimal'
|
const common = {
|
||||||
},
|
|
||||||
entry: {
|
|
||||||
'app/main': './src/app/main.ts'
|
|
||||||
},
|
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
@ -38,10 +34,31 @@ module.exports = {
|
|||||||
use: 'ts-loader',
|
use: 'ts-loader',
|
||||||
exclude: /node_modules\/(?!(@bitwarden)\/).*/
|
exclude: /node_modules\/(?!(@bitwarden)\/).*/
|
||||||
},
|
},
|
||||||
{
|
]
|
||||||
test: /\.node$/,
|
},
|
||||||
loader: 'node-loader'
|
plugins: [],
|
||||||
},
|
resolve: {
|
||||||
|
extensions: ['.tsx', '.ts', '.js'],
|
||||||
|
alias: {
|
||||||
|
jslib: path.join(__dirname, 'node_modules/@bitwarden/jslib/src')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
filename: '[name].js',
|
||||||
|
path: path.resolve(__dirname, 'build')
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const renderer = {
|
||||||
|
target: 'electron-renderer',
|
||||||
|
node: {
|
||||||
|
__dirname: false
|
||||||
|
},
|
||||||
|
entry: {
|
||||||
|
'app/main': './src/app/main.ts'
|
||||||
|
},
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
{
|
{
|
||||||
test: /\.(html)$/,
|
test: /\.(html)$/,
|
||||||
loader: 'html-loader'
|
loader: 'html-loader'
|
||||||
@ -55,13 +72,23 @@ module.exports = {
|
|||||||
outputPath: 'fonts/'
|
outputPath: 'fonts/'
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
test: /\.scss$/,
|
||||||
|
use: extractCss.extract({
|
||||||
|
use: [
|
||||||
|
{
|
||||||
|
loader: 'css-loader',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
loader: 'sass-loader',
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
new CleanWebpackPlugin([
|
|
||||||
path.resolve(__dirname, 'build/*')
|
|
||||||
]),
|
|
||||||
new GoogleFontsPlugin({
|
new GoogleFontsPlugin({
|
||||||
fonts: [
|
fonts: [
|
||||||
{
|
{
|
||||||
@ -85,18 +112,12 @@ module.exports = {
|
|||||||
filename: 'index.html',
|
filename: 'index.html',
|
||||||
chunks: ['app/vendor', 'app/main']
|
chunks: ['app/vendor', 'app/main']
|
||||||
}),
|
}),
|
||||||
new CopyWebpackPlugin([
|
new webpack.SourceMapDevToolPlugin({
|
||||||
'./src/package.json',
|
filename: '[name].js.map',
|
||||||
])
|
include: ['app/main.js']
|
||||||
],
|
}),
|
||||||
resolve: {
|
extractCss
|
||||||
extensions: ['.tsx', '.ts', '.js'],
|
]
|
||||||
alias: {
|
|
||||||
jslib: path.join(__dirname, 'node_modules/@bitwarden/jslib/src')
|
|
||||||
}
|
|
||||||
},
|
|
||||||
output: {
|
|
||||||
filename: '[name].js',
|
|
||||||
path: path.resolve(__dirname, 'build')
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
module.exports = merge(common, renderer);
|
Loading…
Reference in New Issue
Block a user