mirror of
https://github.com/bitwarden/web
synced 2025-12-06 00:03:28 +00:00
@@ -1,7 +1,7 @@
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const webpack = require('webpack');
|
||||
const CleanWebpackPlugin = require('clean-webpack-plugin');
|
||||
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
||||
@@ -68,12 +68,14 @@ const moduleRules = [
|
||||
test: /[\/\\]@angular[\/\\].+\.js$/,
|
||||
parser: { system: true },
|
||||
},
|
||||
{
|
||||
test: /(?:\.ngfactory\.js|\.ngstyle\.js|\.ts)$/,
|
||||
loader: '@ngtools/webpack',
|
||||
},
|
||||
];
|
||||
|
||||
const plugins = [
|
||||
new CleanWebpackPlugin([
|
||||
path.resolve(__dirname, 'build/*'),
|
||||
]),
|
||||
new CleanWebpackPlugin(),
|
||||
// ref: https://github.com/angular/angular/issues/20357
|
||||
new webpack.ContextReplacementPlugin(/\@angular(\\|\/)core(\\|\/)fesm5/,
|
||||
path.resolve(__dirname, './src')),
|
||||
@@ -107,20 +109,22 @@ const plugins = [
|
||||
filename: 'sso-connector.html',
|
||||
chunks: ['connectors/sso'],
|
||||
}),
|
||||
new CopyWebpackPlugin([
|
||||
{ from: './src/.nojekyll' },
|
||||
{ from: './src/manifest.json' },
|
||||
{ from: './src/favicon.ico' },
|
||||
{ from: './src/browserconfig.xml' },
|
||||
{ from: './src/app-id.json' },
|
||||
{ from: './src/404.html' },
|
||||
{ from: './src/404', to: '404' },
|
||||
{ from: './src/images', to: 'images' },
|
||||
{ from: './src/locales', to: 'locales' },
|
||||
{ from: './src/scripts', to: 'scripts' },
|
||||
{ from: './node_modules/qrious/dist/qrious.min.js', to: 'scripts' },
|
||||
{ from: './node_modules/braintree-web-drop-in/dist/browser/dropin.js', to: 'scripts' },
|
||||
]),
|
||||
new CopyWebpackPlugin({
|
||||
patterns:[
|
||||
{ from: './src/.nojekyll' },
|
||||
{ from: './src/manifest.json' },
|
||||
{ from: './src/favicon.ico' },
|
||||
{ from: './src/browserconfig.xml' },
|
||||
{ from: './src/app-id.json' },
|
||||
{ from: './src/404.html' },
|
||||
{ from: './src/404', to: '404' },
|
||||
{ from: './src/images', to: 'images' },
|
||||
{ from: './src/locales', to: 'locales' },
|
||||
{ from: './src/scripts', to: 'scripts' },
|
||||
{ from: './node_modules/qrious/dist/qrious.min.js', to: 'scripts' },
|
||||
{ from: './node_modules/braintree-web-drop-in/dist/browser/dropin.js', to: 'scripts' },
|
||||
],
|
||||
}),
|
||||
new MiniCssExtractPlugin({
|
||||
filename: '[name].[hash].css',
|
||||
chunkFilename: '[id].[hash].css',
|
||||
@@ -133,25 +137,12 @@ const plugins = [
|
||||
'CACHE_TAG': JSON.stringify(Math.random().toString(36).substring(7)),
|
||||
}
|
||||
}),
|
||||
];
|
||||
|
||||
if (NODE_ENV === 'production') {
|
||||
moduleRules.push({
|
||||
test: /(?:\.ngfactory\.js|\.ngstyle\.js|\.ts)$/,
|
||||
loader: '@ngtools/webpack',
|
||||
});
|
||||
plugins.push(new AngularCompilerPlugin({
|
||||
new AngularCompilerPlugin({
|
||||
tsConfigPath: 'tsconfig.json',
|
||||
entryModule: 'src/app/app.module#AppModule',
|
||||
sourceMap: true,
|
||||
}));
|
||||
} else {
|
||||
moduleRules.push({
|
||||
test: /\.ts$/,
|
||||
loaders: ['ts-loader', 'angular2-template-loader'],
|
||||
exclude: path.resolve(__dirname, 'node_modules'),
|
||||
});
|
||||
}
|
||||
}),
|
||||
];
|
||||
|
||||
// ref: https://webpack.js.org/configuration/dev-server/#devserver
|
||||
let certSuffix = fs.existsSync('dev-server.local.pem') ? '.local' : '.shared';
|
||||
|
||||
Reference in New Issue
Block a user