1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-25 12:15:18 +01:00

JIT builds for dev

This commit is contained in:
Kyle Spearrin 2018-04-13 16:03:37 -04:00
parent dc35577564
commit 191042411c
5 changed files with 163 additions and 123 deletions

View File

@ -65,6 +65,7 @@ gulp.task('dist', ['dist:firefox', 'dist:chrome', 'dist:opera', 'dist:edge', 'di
gulp.task('dist:firefox', (cb) => {
return dist('firefox', (manifest) => {
delete manifest['-ms-preload'];
delete manifest.content_security_policy;
return manifest;
});
});
@ -73,6 +74,7 @@ gulp.task('dist:opera', (cb) => {
return dist('opera', (manifest) => {
delete manifest['-ms-preload'];
delete manifest.applications;
delete manifest.content_security_policy;
return manifest;
});
});
@ -81,6 +83,7 @@ gulp.task('dist:chrome', (cb) => {
return dist('chrome', (manifest) => {
delete manifest['-ms-preload'];
delete manifest.applications;
delete manifest.content_security_policy;
delete manifest.sidebar_action;
delete manifest.commands._execute_sidebar_action;
return manifest;
@ -116,6 +119,7 @@ function edgeCopyBuild(source, dest) {
delete manifest.applications;
delete manifest.sidebar_action;
delete manifest.commands._execute_sidebar_action;
delete manifest.content_security_policy;
return manifest;
})))
.pipe(gulp.dest(dest))

23
package-lock.json generated
View File

@ -655,6 +655,29 @@
"integrity": "sha1-n4NQykghRaRNARp1W4+zYj1gVEw=",
"dev": true
},
"angular2-template-loader": {
"version": "0.6.2",
"resolved": "https://registry.npmjs.org/angular2-template-loader/-/angular2-template-loader-0.6.2.tgz",
"integrity": "sha1-wNROkP/w+sleiyPwQ6zaf9HFHXw=",
"dev": true,
"requires": {
"loader-utils": "0.2.17"
},
"dependencies": {
"loader-utils": {
"version": "0.2.17",
"resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-0.2.17.tgz",
"integrity": "sha1-+G5jdNQyBabmxg6RlvF8Apm/s0g=",
"dev": true,
"requires": {
"big.js": "3.2.0",
"emojis-list": "2.1.0",
"json5": "0.5.1",
"object-assign": "4.1.1"
}
}
}
},
"angular2-toaster": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/angular2-toaster/-/angular2-toaster-4.0.2.tgz",

View File

@ -35,6 +35,7 @@
"@types/tldjs": "1.7.1",
"@types/webcrypto": "^0.0.28",
"angular": "1.6.9",
"angular2-template-loader": "^0.6.2",
"angular-animate": "1.6.9",
"angular-sweetalert": "1.1.2",
"angular-toastr": "2.1.1",

View File

@ -78,6 +78,7 @@
"webRequest",
"webRequestBlocking"
],
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
"commands": {
"autofill_login": {
"suggested_key": {

View File

@ -24,41 +24,12 @@ const extractCss = new ExtractTextPlugin({
allChunks: true,
});
const config = {
entry: {
'popup/main': './src/popup/main.ts',
'background': './src/background.ts',
'content/autofill': './src/content/autofill.js',
'content/autofiller': './src/content/autofiller.js',
'content/notificationBar': './src/content/notificationBar.js',
'content/shortcuts': './src/content/shortcuts.js',
'notification/bar': './src/notification/bar.js',
'downloader/downloader': './src/downloader/downloader.ts',
'2fa/2fa': './src/2fa/2fa.ts',
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
alias: {
jslib: path.join(__dirname, 'jslib/src'),
},
symlinks: false,
modules: [path.resolve('node_modules')],
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'build'),
},
module: {
rules: [
const moduleRules = [
{
test: /\.ts$/,
enforce: 'pre',
loader: 'tslint-loader',
},
{
test: /(?:\.ngfactory\.js|\.ngstyle\.js|\.ts)$/,
loader: '@ngtools/webpack',
},
{
test: /\.(html)$/,
loader: 'html-loader',
@ -101,17 +72,12 @@ const config = {
publicPath: '../',
}),
},
],
},
plugins: [
];
const plugins = [
new CleanWebpackPlugin([
path.resolve(__dirname, 'build/*'),
]),
new AngularCompilerPlugin({
tsConfigPath: 'tsconfig.json',
entryModule: 'src/popup/app.module#AppModule',
sourceMap: true,
}),
// ref: https://github.com/angular/angular/issues/20357
new webpack.ContextReplacementPlugin(/\@angular(\\|\/)core(\\|\/)esm5/,
path.resolve(__dirname, './src')),
@ -169,7 +135,52 @@ const config = {
'ENV': JSON.stringify(ENV)
}
}),
],
];
if (ENV === 'production') {
moduleRules.push({
test: /(?:\.ngfactory\.js|\.ngstyle\.js|\.ts)$/,
loader: '@ngtools/webpack',
});
plugins.push(new AngularCompilerPlugin({
tsConfigPath: 'tsconfig.json',
entryModule: 'src/popup/app.module#AppModule',
sourceMap: true,
}));
} else {
moduleRules.push({
test: /\.ts$/,
loaders: ['ts-loader', 'angular2-template-loader'],
exclude: path.resolve(__dirname, 'node_modules'),
});
}
const config = {
entry: {
'popup/main': './src/popup/main.ts',
'background': './src/background.ts',
'content/autofill': './src/content/autofill.js',
'content/autofiller': './src/content/autofiller.js',
'content/notificationBar': './src/content/notificationBar.js',
'content/shortcuts': './src/content/shortcuts.js',
'notification/bar': './src/notification/bar.js',
'downloader/downloader': './src/downloader/downloader.ts',
'2fa/2fa': './src/2fa/2fa.ts',
},
resolve: {
extensions: ['.ts', '.js'],
alias: {
jslib: path.join(__dirname, 'jslib/src'),
},
symlinks: false,
modules: [path.resolve('node_modules')],
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'build'),
},
module: { rules: moduleRules },
plugins: plugins,
};
module.exports = config;