mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
dependency upgrades, server and platform module updates, linting wip
This commit is contained in:
13
webpack/helpers.js
Normal file
13
webpack/helpers.js
Normal file
@@ -0,0 +1,13 @@
|
||||
const {
|
||||
join,
|
||||
resolve
|
||||
} = require('path');
|
||||
|
||||
function root(path) {
|
||||
return resolve(__dirname, '..', path);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
root: root,
|
||||
join: join
|
||||
};
|
24
webpack/webpack.client.js
Normal file
24
webpack/webpack.client.js
Normal file
@@ -0,0 +1,24 @@
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
const ScriptExtPlugin = require('script-ext-html-webpack-plugin');
|
||||
|
||||
const {
|
||||
root
|
||||
} = require('./helpers');
|
||||
|
||||
module.exports = {
|
||||
entry: root('./src/main.browser.ts'),
|
||||
output: {
|
||||
filename: 'client.js'
|
||||
},
|
||||
target: 'web',
|
||||
plugins: [
|
||||
new HtmlWebpackPlugin({
|
||||
template: root('./src/index.html'),
|
||||
output: root('dist'),
|
||||
inject: 'head'
|
||||
}),
|
||||
new ScriptExtPlugin({
|
||||
defaultAttribute: 'defer'
|
||||
})
|
||||
]
|
||||
};
|
102
webpack/webpack.common.js
Normal file
102
webpack/webpack.common.js
Normal file
@@ -0,0 +1,102 @@
|
||||
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
||||
|
||||
const {
|
||||
root,
|
||||
join
|
||||
} = require('./helpers');
|
||||
|
||||
module.exports = {
|
||||
devtool: 'source-map',
|
||||
resolve: {
|
||||
extensions: ['.ts', '.js', '.json']
|
||||
},
|
||||
output: {
|
||||
path: root('dist')
|
||||
},
|
||||
module: {
|
||||
rules: [{
|
||||
test: /\.ts$/,
|
||||
enforce: 'pre',
|
||||
loader: 'tslint-loader'
|
||||
}, {
|
||||
test: /\.ts$/,
|
||||
loader: '@ngtools/webpack'
|
||||
}, {
|
||||
test: /\.css$/,
|
||||
use: [{
|
||||
loader: 'to-string-loader',
|
||||
options: {
|
||||
sourceMap: true
|
||||
}
|
||||
},
|
||||
{
|
||||
loader: 'css-loader',
|
||||
options: {
|
||||
sourceMap: true
|
||||
}
|
||||
},
|
||||
{
|
||||
loader: 'postcss-loader',
|
||||
options: {
|
||||
sourceMap: true
|
||||
}
|
||||
}
|
||||
]
|
||||
}, {
|
||||
test: /\.scss$/,
|
||||
exclude: /node_modules/,
|
||||
use: [{
|
||||
loader: 'to-string-loader',
|
||||
options: {
|
||||
sourceMap: true
|
||||
}
|
||||
}, {
|
||||
loader: 'raw-loader',
|
||||
options: {
|
||||
sourceMap: true
|
||||
}
|
||||
},
|
||||
{
|
||||
loader: 'postcss-loader',
|
||||
options: {
|
||||
sourceMap: true
|
||||
}
|
||||
},
|
||||
{
|
||||
loader: 'resolve-url-loader',
|
||||
options: {
|
||||
sourceMap: true
|
||||
}
|
||||
},
|
||||
{
|
||||
loader: 'sass-loader',
|
||||
options: {
|
||||
sourceMap: true
|
||||
}
|
||||
}
|
||||
]
|
||||
}, {
|
||||
test: /\.html$/,
|
||||
loader: 'raw-loader'
|
||||
}, {
|
||||
test: /\.json$/,
|
||||
loader: 'json-loader'
|
||||
}]
|
||||
},
|
||||
plugins: [
|
||||
new CopyWebpackPlugin([{
|
||||
from: join(__dirname, '..', 'node_modules', 'font-awesome', 'fonts'),
|
||||
to: join('assets', 'fonts')
|
||||
}, {
|
||||
from: join(__dirname, '..', 'resources', 'images'),
|
||||
to: join('assets', 'images')
|
||||
}, {
|
||||
from: join(__dirname, '..', 'resources', 'data'),
|
||||
to: join('assets', 'data')
|
||||
}, {
|
||||
from: join(__dirname, '..', 'resources', 'i18n'),
|
||||
to: join('assets', 'i18n')
|
||||
}])
|
||||
]
|
||||
|
||||
};
|
60
webpack/webpack.prod.js
Normal file
60
webpack/webpack.prod.js
Normal file
@@ -0,0 +1,60 @@
|
||||
const webpack = require('webpack');
|
||||
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
||||
const CompressionPlugin = require("compression-webpack-plugin");
|
||||
|
||||
const {
|
||||
root
|
||||
} = require('./helpers');
|
||||
|
||||
module.exports = {
|
||||
recordsOutputPath: root('webpack.records.json'),
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
'process.env.NODE_ENV': JSON.stringify('production'),
|
||||
'process.env.AOT': true
|
||||
}),
|
||||
|
||||
// Loader options
|
||||
new webpack.LoaderOptionsPlugin({
|
||||
minimize: true,
|
||||
debug: false
|
||||
}),
|
||||
|
||||
new BundleAnalyzerPlugin({
|
||||
analyzerMode: 'disabled', // change it to `server` to view bundle stats
|
||||
reportFilename: 'report.html',
|
||||
generateStatsFile: true,
|
||||
statsFilename: 'stats.json',
|
||||
}),
|
||||
|
||||
new webpack.optimize.UglifyJsPlugin({
|
||||
beautify: false,
|
||||
mangle: false,
|
||||
output: {
|
||||
comments: false
|
||||
},
|
||||
compress: {
|
||||
warnings: false,
|
||||
conditionals: false,
|
||||
unused: true,
|
||||
comparisons: true,
|
||||
sequences: true,
|
||||
dead_code: true,
|
||||
evaluate: true,
|
||||
if_return: true,
|
||||
join_vars: true,
|
||||
negate_iife: true
|
||||
},
|
||||
sourceMap: true
|
||||
}),
|
||||
|
||||
new CompressionPlugin({
|
||||
asset: "[path].gz[query]",
|
||||
algorithm: "gzip",
|
||||
test: /\.js$|\.css$|\.html$/,
|
||||
threshold: 10240,
|
||||
minRatio: 0.8
|
||||
})
|
||||
|
||||
]
|
||||
};
|
11
webpack/webpack.server.js
Normal file
11
webpack/webpack.server.js
Normal file
@@ -0,0 +1,11 @@
|
||||
const {
|
||||
root
|
||||
} = require('./helpers');
|
||||
|
||||
module.exports = {
|
||||
entry: root('./src/main.server.ts'),
|
||||
output: {
|
||||
filename: 'server.js'
|
||||
},
|
||||
target: 'node'
|
||||
};
|
302
webpack/webpack.test.js
Normal file
302
webpack/webpack.test.js
Normal file
@@ -0,0 +1,302 @@
|
||||
const path = require('path');
|
||||
|
||||
const {
|
||||
root
|
||||
} = require('./helpers');
|
||||
|
||||
/**
|
||||
* Webpack Plugins
|
||||
*/
|
||||
const ProvidePlugin = require('webpack/lib/ProvidePlugin');
|
||||
const DefinePlugin = require('webpack/lib/DefinePlugin');
|
||||
const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin');
|
||||
const ContextReplacementPlugin = require('webpack/lib/ContextReplacementPlugin');
|
||||
|
||||
/**
|
||||
* Webpack Constants
|
||||
*/
|
||||
const ENV = process.env.ENV = process.env.NODE_ENV = 'test';
|
||||
|
||||
/**
|
||||
* Webpack configuration
|
||||
*
|
||||
* See: http://webpack.github.io/docs/configuration.html#cli
|
||||
*/
|
||||
module.exports = function (options) {
|
||||
return {
|
||||
|
||||
/**
|
||||
* Source map for Karma from the help of karma-sourcemap-loader & karma-webpack
|
||||
*
|
||||
* Do not change, leave as is or it wont work.
|
||||
* See: https://github.com/webpack/karma-webpack#source-maps
|
||||
*/
|
||||
devtool: 'inline-source-map',
|
||||
|
||||
/**
|
||||
* Options affecting the resolving of modules.
|
||||
*
|
||||
* See: http://webpack.github.io/docs/configuration.html#resolve
|
||||
*/
|
||||
resolve: {
|
||||
|
||||
/**
|
||||
* An array of extensions that should be used to resolve modules.
|
||||
*
|
||||
* See: http://webpack.github.io/docs/configuration.html#resolve-extensions
|
||||
*/
|
||||
extensions: ['.ts', '.js', '.json'],
|
||||
|
||||
/**
|
||||
* Make sure root is src
|
||||
*/
|
||||
modules: [path.resolve(__dirname, 'src'), 'node_modules']
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Options affecting the normal modules.
|
||||
*
|
||||
* See: http://webpack.github.io/docs/configuration.html#module
|
||||
*
|
||||
* 'use:' revered back to 'loader:' as a temp. workaround for #1188
|
||||
* See: https://github.com/AngularClass/angular2-webpack-starter/issues/1188#issuecomment-262872034
|
||||
*/
|
||||
module: {
|
||||
|
||||
rules: [
|
||||
|
||||
/**
|
||||
* Source map loader support for *.js files
|
||||
* Extracts SourceMaps for source files that as added as sourceMappingURL comment.
|
||||
*
|
||||
* See: https://github.com/webpack/source-map-loader
|
||||
*/
|
||||
{
|
||||
enforce: 'pre',
|
||||
test: /\.js$/,
|
||||
loader: 'source-map-loader',
|
||||
exclude: [
|
||||
// these packages have problems with their sourcemaps
|
||||
root('node_modules/rxjs'),
|
||||
root('node_modules/@angular')
|
||||
]
|
||||
},
|
||||
|
||||
/**
|
||||
* Typescript loader support for .ts and Angular 2 async routes via .async.ts
|
||||
*
|
||||
* See: https://github.com/s-panferov/awesome-typescript-loader
|
||||
*/
|
||||
{
|
||||
test: /\.ts$/,
|
||||
loaders: [{
|
||||
loader: 'awesome-typescript-loader',
|
||||
options: {
|
||||
configFileName: './src/tsconfig.test.json'
|
||||
}
|
||||
},
|
||||
'angular2-template-loader'
|
||||
],
|
||||
exclude: [/\.e2e\.ts$/]
|
||||
},
|
||||
|
||||
/**
|
||||
* CSS loader support for *.css files
|
||||
* Returns file content as string
|
||||
*
|
||||
* See: https://github.com/webpack/css-loader
|
||||
*/
|
||||
{
|
||||
test: /\.css$/,
|
||||
use: [{
|
||||
loader: 'to-string-loader',
|
||||
options: {
|
||||
sourceMap: 'inline'
|
||||
}
|
||||
},
|
||||
{
|
||||
loader: 'css-loader',
|
||||
options: {
|
||||
sourceMap: 'inline'
|
||||
}
|
||||
},
|
||||
{
|
||||
loader: 'postcss-loader',
|
||||
options: {
|
||||
sourceMap: 'inline'
|
||||
}
|
||||
}
|
||||
],
|
||||
exclude: [root('src/index.html')]
|
||||
},
|
||||
|
||||
/**
|
||||
* SASS loader support for *.css files
|
||||
* Returns file content as string
|
||||
*
|
||||
*/
|
||||
{
|
||||
test: /\.scss$/,
|
||||
use: [{
|
||||
loader: 'to-string-loader',
|
||||
options: {
|
||||
sourceMap: 'inline'
|
||||
}
|
||||
}, {
|
||||
loader: 'raw-loader',
|
||||
options: {
|
||||
sourceMap: 'inline'
|
||||
}
|
||||
},
|
||||
{
|
||||
loader: 'postcss-loader',
|
||||
options: {
|
||||
sourceMap: 'inline'
|
||||
}
|
||||
},
|
||||
{
|
||||
loader: 'resolve-url-loader',
|
||||
options: {
|
||||
sourceMap: 'inline'
|
||||
}
|
||||
},
|
||||
{
|
||||
loader: 'sass-loader',
|
||||
options: {
|
||||
sourceMap: 'inline'
|
||||
}
|
||||
}
|
||||
],
|
||||
exclude: [root('src/index.html')]
|
||||
},
|
||||
|
||||
/**
|
||||
* Raw loader support for *.html
|
||||
* Returns file content as string
|
||||
*
|
||||
* See: https://github.com/webpack/raw-loader
|
||||
*/
|
||||
{
|
||||
test: /\.html$/,
|
||||
loader: 'raw-loader',
|
||||
exclude: [root('src/index.html')]
|
||||
},
|
||||
|
||||
/**
|
||||
* Json loader support for *.json files.
|
||||
*
|
||||
* See: https://github.com/webpack/json-loader
|
||||
*/
|
||||
{
|
||||
test: /\.json$/,
|
||||
loader: 'json-loader',
|
||||
exclude: [root('src/index.html')]
|
||||
},
|
||||
|
||||
/**
|
||||
* Instruments JS files with Istanbul for subsequent code coverage reporting.
|
||||
* Instrument only testing sources.
|
||||
*
|
||||
* See: https://github.com/deepsweet/istanbul-instrumenter-loader
|
||||
*/
|
||||
{
|
||||
enforce: 'post',
|
||||
test: /\.(js|ts)$/,
|
||||
loader: 'istanbul-instrumenter-loader',
|
||||
query: {
|
||||
esModules: true
|
||||
},
|
||||
include: root('src'),
|
||||
exclude: [
|
||||
/\.(e2e|spec)\.ts$/,
|
||||
/node_modules/
|
||||
]
|
||||
}
|
||||
|
||||
]
|
||||
},
|
||||
|
||||
/**
|
||||
* Add additional plugins to the compiler.
|
||||
*
|
||||
* See: http://webpack.github.io/docs/configuration.html#plugins
|
||||
*/
|
||||
plugins: [
|
||||
|
||||
/**
|
||||
* Plugin: DefinePlugin
|
||||
* Description: Define free variables.
|
||||
* Useful for having development builds with debug logging or adding global constants.
|
||||
*
|
||||
* Environment helpers
|
||||
*
|
||||
* See: https://webpack.github.io/docs/list-of-plugins.html#defineplugin
|
||||
*/
|
||||
// NOTE: when adding more properties make sure you include them in custom-typings.d.ts
|
||||
new DefinePlugin({
|
||||
'ENV': JSON.stringify(ENV),
|
||||
'HMR': false,
|
||||
'process.env': {
|
||||
'ENV': JSON.stringify(ENV),
|
||||
'NODE_ENV': JSON.stringify(ENV),
|
||||
'HMR': false,
|
||||
}
|
||||
}),
|
||||
|
||||
/**
|
||||
* Plugin: ContextReplacementPlugin
|
||||
* Description: Provides context to Angular's use of System.import
|
||||
*
|
||||
* See: https://webpack.github.io/docs/list-of-plugins.html#contextreplacementplugin
|
||||
* See: https://github.com/angular/angular/issues/11580
|
||||
*/
|
||||
new ContextReplacementPlugin(
|
||||
// The (\\|\/) piece accounts for path separators in *nix and Windows
|
||||
/angular(\\|\/)core(\\|\/)@angular/,
|
||||
root('src'), // location of your src
|
||||
{
|
||||
// your Angular Async Route paths relative to this root directory
|
||||
}
|
||||
),
|
||||
|
||||
/**
|
||||
* Plugin LoaderOptionsPlugin (experimental)
|
||||
*
|
||||
* See: https://gist.github.com/sokra/27b24881210b56bbaff7
|
||||
*/
|
||||
new LoaderOptionsPlugin({
|
||||
debug: false,
|
||||
options: {
|
||||
|
||||
}
|
||||
}),
|
||||
|
||||
],
|
||||
|
||||
/**
|
||||
* Disable performance hints
|
||||
*
|
||||
* See: https://github.com/a-tarasyuk/rr-boilerplate/blob/master/webpack/dev.config.babel.js#L41
|
||||
*/
|
||||
performance: {
|
||||
hints: false
|
||||
},
|
||||
|
||||
/**
|
||||
* Include polyfills or mocks for various node stuff
|
||||
* Description: Node configuration
|
||||
*
|
||||
* See: https://webpack.github.io/docs/configuration.html#node
|
||||
*/
|
||||
node: {
|
||||
global: true,
|
||||
process: false,
|
||||
crypto: 'empty',
|
||||
module: false,
|
||||
clearImmediate: false,
|
||||
setImmediate: false
|
||||
}
|
||||
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user