const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
const ContextReplacementPlugin = require('webpack/lib/ContextReplacementPlugin')
const CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin')
-const CopyWebpackPlugin = require('copy-webpack-plugin')
const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin
const HtmlWebpackPlugin = require('html-webpack-plugin')
const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin')
const WebpackNotifierPlugin = require('webpack-notifier')
-/*
- * Webpack Constants
- */
+const HMR = helpers.hasProcessFlag('hot')
+const AOT = process.env.BUILD_AOT || helpers.hasNpmFlag('aot')
const METADATA = {
title: 'PeerTube',
baseUrl: '/',
- isDevServer: helpers.isWebpackDevServer()
+ isDevServer: helpers.isWebpackDevServer(),
+ HMR: HMR,
+ AOT: AOT
}
/*
{
test: /\.ts$/,
use: [
- {
- loader: '@angularclass/hmr-loader',
- options: {
- pretty: !isProd,
- prod: isProd
- }
- },
{
loader: 'ng-router-loader',
options: {
/**
* The (\\|\/) piece accounts for path separators in *nix and Windows
*/
- /angular(\\|\/)core(\\|\/)@angular/,
+ /(.+)?angular(\\|\/)core(.+)?/,
helpers.root('src'), // location of your src
{
/**
}
),
- /*
- * Plugin: CopyWebpackPlugin
- * Description: Copy files and directories in webpack.
- *
- * Copies project static assets.
- *
- * See: https://www.npmjs.com/package/copy-webpack-plugin
- */
-
- // Used by embed.html
- new CopyWebpackPlugin([
- {
- from: 'src/assets',
- to: 'assets'
- },
- {
- from: 'node_modules/webtorrent/webtorrent.min.js',
- to: 'assets/webtorrent'
- },
- {
- from: 'node_modules/video.js/dist/video.min.js',
- to: 'assets/video-js'
- },
- {
- from: 'node_modules/video.js/dist/video-js.min.css',
- to: 'assets/video-js'
- },
- {
- from: 'node_modules/videojs-dock/dist/videojs-dock.min.js',
- to: 'assets/video-js'
- },
- {
- from: 'node_modules/videojs-dock/dist/videojs-dock.css',
- to: 'assets/video-js'
- },
- {
- from: 'src/standalone',
- to: 'standalone'
- }
- ]),
-
/*
* Plugin: ScriptExtHtmlWebpackPlugin
* Description: Enhances html-webpack-plugin functionality
new HtmlWebpackPlugin({
template: 'src/index.html',
title: METADATA.title,
- chunksSortMode: 'dependency',
+ chunksSortMode: function (a, b) {
+ const entryPoints = [ 'inline', 'polyfills', 'sw-register', 'styles', 'vendor', 'main' ]
+ return entryPoints.indexOf(a.names[0]) - entryPoints.indexOf(b.names[0])
+ },
metadata: METADATA,
inject: 'body'
}),
new ngcWebpack.NgcWebpackPlugin({
disabled: !AOT,
- tsConfig: helpers.root('tsconfig.webpack.json'),
- resourceOverride: helpers.root('config/resource-override.js')
+ tsConfig: helpers.root('tsconfig.webpack.json')
}),
new BundleAnalyzerPlugin({