Upgrade scripts and embed webpack config

This commit is contained in:
Chocobozzz 2017-12-12 11:38:02 +01:00
parent 63c4db6d71
commit 7bfd1b1edb
No known key found for this signature in database
GPG key ID: 583A612D890159BE
15 changed files with 81 additions and 1986 deletions

View file

@ -1,11 +0,0 @@
module.exports = {
hmrModule: function (ngmodule) {
return ngmodule
},
NgProbeToken: {},
HmrState: function () {},
_createConditionalRootRenderer: function (rootRenderer, extraTokens, coreTokens) {
return rootRenderer
},
__platform_browser_private__: {}
}

View file

@ -1,338 +0,0 @@
const helpers = require('./helpers')
/*
* Webpack Plugins
*/
const AssetsPlugin = require('assets-webpack-plugin')
const ContextReplacementPlugin = require('webpack/lib/ContextReplacementPlugin')
const CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin')
const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin
const HtmlWebpackPlugin = require('html-webpack-plugin')
const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin')
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin')
const InlineManifestWebpackPlugin = require('inline-manifest-webpack-plugin')
const ngcWebpack = require('ngc-webpack')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const WebpackNotifierPlugin = require('webpack-notifier')
const HMR = helpers.hasProcessFlag('hot')
const AOT = process.env.BUILD_AOT || helpers.hasNpmFlag('aot')
const METADATA = {
title: 'PeerTube',
baseUrl: '/',
isDevServer: helpers.isWebpackDevServer(),
HMR: HMR,
AOT: AOT
}
/*
* Webpack configuration
*
* See: http://webpack.github.io/docs/configuration.html#cli
*/
module.exports = function (options) {
const isProd = options.env === 'production'
const AOT = isProd
return {
/*
* Cache generated modules and chunks to improve performance for multiple incremental builds.
* This is enabled by default in watch mode.
* You can pass false to disable it.
*
* See: http://webpack.github.io/docs/configuration.html#cache
*/
// cache: false,
/*
* The entry point for the bundle
* Our Angular.js app
*
* See: http://webpack.github.io/docs/configuration.html#entry
*/
entry: {
'polyfills': './src/polyfills.browser.ts',
'main': AOT
? './src/main.browser.aot.ts'
: './src/main.browser.ts'
},
/*
* 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', '.scss' ],
modules: [ helpers.root('src'), helpers.root('node_modules') ]
},
/*
* Options affecting the normal modules.
*
* See: http://webpack.github.io/docs/configuration.html#module
*/
module: {
rules: [
/*
* Typescript loader support for .ts and Angular async routes via .async.ts
*
* See: https://github.com/s-panferov/awesome-typescript-loader
*/
{
test: /\.ts$/,
use: [
{
loader: 'ng-router-loader',
options: {
loader: 'async-import',
genDir: 'compiled',
aot: AOT
}
},
{
loader: 'awesome-typescript-loader',
options: {
configFileName: 'tsconfig.webpack.json',
useCache: !isProd
}
},
{
loader: 'angular2-template-loader'
}
],
exclude: [/\.(spec|e2e)\.ts$/]
},
/*
* Json loader support for *.json files.
*
* See: https://github.com/webpack/json-loader
*/
{
test: /\.json$/,
use: 'json-loader'
},
{
test: /\.(sass|scss)$/,
use: [
'css-to-string-loader',
{
loader: 'css-loader',
options: {
sourceMap: true,
importLoaders: 1
}
},
'resolve-url-loader',
{
loader: 'sass-loader',
options: {
sourceMap: true
}
},
{
loader: 'sass-resources-loader',
options: {
resources: [
helpers.root('src/sass/_variables.scss'),
helpers.root('src/sass/_mixins.scss')
]
}
}
]
},
{ test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, use: 'url-loader?limit=10000&minetype=application/font-woff' },
{ test: /\.(otf|ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, use: 'url-loader?limit=10000' },
/* Raw loader support for *.html
* Returns file content as string
*
* See: https://github.com/webpack/raw-loader
*/
{
test: /\.html$/,
use: 'raw-loader',
exclude: [
helpers.root('src/index.html'),
helpers.root('src/standalone/videos/embed.html')
]
},
/* File loader for supporting images, for example, in CSS files.
*/
{
test: /\.(jpg|png|gif)$/,
use: 'url-loader'
}
]
},
/*
* Add additional plugins to the compiler.
*
* See: http://webpack.github.io/docs/configuration.html#plugins
*/
plugins: [
new AssetsPlugin({
path: helpers.root('dist'),
filename: 'webpack-assets.json',
prettyPrint: true
}),
/*
* Plugin: ForkCheckerPlugin
* Description: Do type checking in a separate process, so webpack don't need to wait.
*
* See: https://github.com/s-panferov/awesome-typescript-loader#forkchecker-boolean-defaultfalse
*/
new CheckerPlugin(),
/*
* Plugin: CommonsChunkPlugin
* Description: Shares common code between the pages.
* It identifies common modules and put them into a commons chunk.
*
* See: https://webpack.github.io/docs/list-of-plugins.html#commonschunkplugin
* See: https://github.com/webpack/docs/wiki/optimization#multi-page-app
*/
new CommonsChunkPlugin({
name: 'polyfills',
chunks: ['polyfills']
}),
// This enables tree shaking of the vendor modules
new CommonsChunkPlugin({
name: 'vendor',
chunks: ['main'],
minChunks: module => {
return /node_modules\//.test(module.resource)
}
}),
// Specify the correct order the scripts will be injected in
new CommonsChunkPlugin({
name: ['polyfills', 'vendor'].reverse()
}),
/**
* 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(.+)?/,
helpers.root('src'), // location of your src
{
/**
* Your Angular Async Route paths relative to this root directory
*/
}
),
/*
* Plugin: HtmlWebpackPlugin
* Description: Simplifies creation of HTML files to serve your webpack bundles.
* This is especially useful for webpack bundles that include a hash in the filename
* which changes every compilation.
*
* See: https://github.com/ampedandwired/html-webpack-plugin
*/
new HtmlWebpackPlugin({
template: 'src/index.html',
title: METADATA.title,
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 CopyWebpackPlugin([
{
from: helpers.root('src/assets/images/favicon.png'),
to: 'assets/images/favicon.png'
},
{
from: helpers.root('src/assets/images/default-avatar.png'),
to: 'assets/images/default-avatar.png'
}
]),
/*
* Plugin: ScriptExtHtmlWebpackPlugin
* Description: Enhances html-webpack-plugin functionality
* with different deployment options for your scripts including:
*
* See: https://github.com/numical/script-ext-html-webpack-plugin
*/
new ScriptExtHtmlWebpackPlugin({
sync: [ /polyfill|vendor/ ],
defaultAttribute: 'async',
preload: [/polyfill|vendor|main/],
prefetch: [/chunk/]
}),
new WebpackNotifierPlugin({ alwaysNotify: true }),
/**
* Plugin LoaderOptionsPlugin (experimental)
*
* See: https://gist.github.com/sokra/27b24881210b56bbaff7
*/
new LoaderOptionsPlugin({
options: {
context: '',
sassLoader: {
precision: 10,
includePaths: [ helpers.root('src/sass') ]
}
}
}),
new ngcWebpack.NgcWebpackPlugin({
disabled: !AOT,
tsConfig: helpers.root('tsconfig.webpack.json')
}),
new InlineManifestWebpackPlugin()
],
/*
* Include polyfills or mocks for various node stuff
* Description: Node configuration
*
* See: https://webpack.github.io/docs/configuration.html#node
*/
node: {
global: true,
crypto: 'empty',
process: true,
module: false,
clearImmediate: false,
setImmediate: false,
setInterval: false,
setTimeout: false
}
}
}

View file

@ -1,242 +0,0 @@
const helpers = require('./helpers')
const webpackMerge = require('webpack-merge') // used to merge webpack configs
const webpackMergeDll = webpackMerge.strategy({plugins: 'replace'})
const commonConfig = require('./webpack.common.js') // the settings that are common to prod and dev
const videoEmbedConfig = require('./webpack.video-embed.js')
/**
* Webpack Plugins
*/
const AddAssetHtmlPlugin = require('add-asset-html-webpack-plugin')
const DefinePlugin = require('webpack/lib/DefinePlugin')
const NamedModulesPlugin = require('webpack/lib/NamedModulesPlugin')
const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin')
const HotModuleReplacementPlugin = require('webpack/lib/HotModuleReplacementPlugin')
/**
* Webpack Constants
*/
const ENV = process.env.ENV = process.env.NODE_ENV = 'development'
const HOST = process.env.HOST || 'localhost'
const PORT = process.env.PORT || 3000
const PUBLIC = process.env.PUBLIC_DEV || HOST + ':' + PORT
const AOT = process.env.BUILD_AOT || helpers.hasNpmFlag('aot')
const HMR = helpers.hasProcessFlag('hot')
const METADATA = {
host: HOST,
port: PORT,
public: PUBLIC,
ENV: ENV,
HMR: HMR,
AOT: AOT,
API_URL: 'http://localhost:9000'
}
const DllBundlesPlugin = require('webpack-dll-bundles-plugin').DllBundlesPlugin
/**
* Webpack configuration
*
* See: http://webpack.github.io/docs/configuration.html#cli
*/
module.exports = function (env) {
return [
webpackMerge(commonConfig({ env: ENV }), {
/**
* Developer tool to enhance debugging
*
* See: http://webpack.github.io/docs/configuration.html#devtool
* See: https://github.com/webpack/docs/wiki/build-performance#sourcemaps
*/
devtool: 'cheap-module-source-map',
/**
* Options affecting the output of the compilation.
*
* See: http://webpack.github.io/docs/configuration.html#output
*/
output: {
/**
* The output directory as absolute path (required).
*
* See: http://webpack.github.io/docs/configuration.html#output-path
*/
path: helpers.root('dist'),
/**
* Specifies the name of each output file on disk.
* IMPORTANT: You must not specify an absolute path here!
*
* See: http://webpack.github.io/docs/configuration.html#output-filename
*/
filename: '[name].bundle.js',
/**
* The filename of the SourceMaps for the JavaScript files.
* They are inside the output.path directory.
*
* See: http://webpack.github.io/docs/configuration.html#output-sourcemapfilename
*/
sourceMapFilename: '[name].map',
/** The filename of non-entry chunks as relative path
* inside the output.path directory.
*
* See: http://webpack.github.io/docs/configuration.html#output-chunkfilename
*/
chunkFilename: '[id].chunk.js',
library: 'ac_[name]',
libraryTarget: 'var'
},
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(METADATA.ENV),
'HMR': METADATA.HMR,
'API_URL': JSON.stringify(METADATA.API_URL),
'process.version': JSON.stringify(process.version),
'process.env.ENV': JSON.stringify(METADATA.ENV),
'process.env.NODE_ENV': JSON.stringify(METADATA.ENV),
'process.env.HMR': METADATA.HMR
}),
new DllBundlesPlugin({
bundles: {
polyfills: [
'core-js',
{
name: 'zone.js',
path: 'zone.js/dist/zone.js'
},
{
name: 'zone.js',
path: 'zone.js/dist/long-stack-trace-zone.js'
}
],
vendor: [
'@angular/platform-browser',
'@angular/platform-browser-dynamic',
'@angular/core',
'@angular/common',
'@angular/forms',
'@angular/http',
'@angular/router',
'@angularclass/hmr',
'rxjs'
]
},
dllDir: helpers.root('dll'),
webpackConfig: webpackMergeDll(commonConfig({env: ENV}), {
devtool: 'cheap-module-source-map',
plugins: []
})
}),
/**
* Plugin: AddAssetHtmlPlugin
* Description: Adds the given JS or CSS file to the files
* Webpack knows about, and put it into the list of assets
* html-webpack-plugin injects into the generated html.
*
* See: https://github.com/SimenB/add-asset-html-webpack-plugin
*/
new AddAssetHtmlPlugin([
{ filepath: helpers.root(`dll/${DllBundlesPlugin.resolveFile('polyfills')}`) },
{ filepath: helpers.root(`dll/${DllBundlesPlugin.resolveFile('vendor')}`) }
]),
/**
* Plugin: NamedModulesPlugin (experimental)
* Description: Uses file names as module name.
*
* See: https://github.com/webpack/webpack/commit/a04ffb928365b19feb75087c63f13cadfc08e1eb
*/
new NamedModulesPlugin(),
/**
* Plugin LoaderOptionsPlugin (experimental)
*
* See: https://gist.github.com/sokra/27b24881210b56bbaff7
*/
new LoaderOptionsPlugin({
debug: true,
options: {
/**
* Static analysis linter for TypeScript advanced options configuration
* Description: An extensible linter for the TypeScript language.
*
* See: https://github.com/wbuchwalter/tslint-loader
*/
tslint: {
emitErrors: false,
failOnHint: false,
typeCheck: true,
resourcePath: 'src'
},
// FIXME: Remove
// https://github.com/bholloway/resolve-url-loader/issues/36
// https://github.com/jtangelder/sass-loader/issues/289
context: __dirname,
output: {
path: helpers.root('dist')
}
}
}),
new HotModuleReplacementPlugin()
],
/**
* Webpack Development Server configuration
* Description: The webpack-dev-server is a little node.js Express server.
* The server emits information about the compilation state to the client,
* which reacts to those events.
*
* See: https://webpack.github.io/docs/webpack-dev-server.html
*/
devServer: {
port: METADATA.port,
host: METADATA.host,
historyApiFallback: true,
hot: METADATA.HMR,
watchOptions: {
ignored: /node_modules/
}
},
/*
* Include polyfills or mocks for various node stuff
* Description: Node configuration
*
* See: https://webpack.github.io/docs/configuration.html#node
*/
node: {
global: true,
crypto: 'empty',
fs: 'empty',
process: true,
module: false,
clearImmediate: false,
setImmediate: false
}
}),
videoEmbedConfig({env: ENV})
]
}

View file

@ -1,293 +0,0 @@
/**
* @author: @AngularClass
*/
const helpers = require('./helpers')
const webpackMerge = require('webpack-merge') // used to merge webpack configs
const commonConfig = require('./webpack.common.js') // the settings that are common to prod and dev
const videoEmbedConfig = require('./webpack.video-embed.js')
/**
* Webpack Plugins
*/
const DefinePlugin = require('webpack/lib/DefinePlugin')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin')
const NormalModuleReplacementPlugin = require('webpack/lib/NormalModuleReplacementPlugin')
const OptimizeJsPlugin = require('optimize-js-plugin')
const HashedModuleIdsPlugin = require('webpack/lib/HashedModuleIdsPlugin')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
/**
* Webpack Constants
*/
const ENV = process.env.NODE_ENV = process.env.ENV = 'production'
const HOST = process.env.HOST || 'localhost'
const PORT = process.env.PORT || 8080
const AOT = process.env.BUILD_AOT || helpers.hasNpmFlag('aot')
const METADATA = {
host: HOST,
port: PORT,
ENV: ENV,
HMR: false,
AOT: AOT,
API_URL: ''
}
module.exports = function (env) {
return [
videoEmbedConfig({ env: ENV }),
webpackMerge(commonConfig({ env: ENV }), {
/**
* Developer tool to enhance debugging
*
* See: http://webpack.github.io/docs/configuration.html#devtool
* See: https://github.com/webpack/docs/wiki/build-performance#sourcemaps
*/
devtool: 'source-map',
/**
* Options affecting the output of the compilation.
*
* See: http://webpack.github.io/docs/configuration.html#output
*/
output: {
/**
* The output directory as absolute path (required).
*
* See: http://webpack.github.io/docs/configuration.html#output-path
*/
path: helpers.root('dist'),
/**
* Specifies the name of each output file on disk.
* IMPORTANT: You must not specify an absolute path here!
*
* See: http://webpack.github.io/docs/configuration.html#output-filename
*/
filename: '[name].[chunkhash].bundle.js',
/**
* The filename of the SourceMaps for the JavaScript files.
* They are inside the output.path directory.
*
* See: http://webpack.github.io/docs/configuration.html#output-sourcemapfilename
*/
sourceMapFilename: '[file].map',
/**
* The filename of non-entry chunks as relative path
* inside the output.path directory.
*
* See: http://webpack.github.io/docs/configuration.html#output-chunkfilename
*/
chunkFilename: '[name].[chunkhash].chunk.js',
publicPath: '/client/'
},
module: {
rules: [
{
test: /junk\/index\.js$/,
// exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: [ 'env' ]
}
}
}
]
},
/**
* Add additional plugins to the compiler.
*
* See: http://webpack.github.io/docs/configuration.html#plugins
*/
plugins: [
/**
* Webpack plugin to optimize a JavaScript file for faster initial load
* by wrapping eagerly-invoked functions.
*
* See: https://github.com/vigneshshanmugam/optimize-js-plugin
*/
new OptimizeJsPlugin({
sourceMap: false
}),
new ExtractTextPlugin({
filename: '[name].[contenthash].css',
allChunks: true
}),
/**
* 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(METADATA.ENV),
'HMR': METADATA.HMR,
'API_URL': JSON.stringify(METADATA.API_URL),
'AOT': METADATA.AOT,
'process.version': JSON.stringify(process.version),
'process.env.ENV': JSON.stringify(METADATA.ENV),
'process.env.NODE_ENV': JSON.stringify(METADATA.ENV),
'process.env.HMR': METADATA.HMR
}),
/**
* Plugin: UglifyJsPlugin
* Description: Minimize all JavaScript output of chunks.
* Loaders are switched into minimizing mode.
*
* See: https://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin
*/
new UglifyJsPlugin({
parallel: true,
uglifyOptions: {
ie8: false,
ecma: 6,
warnings: false,
mangle: true,
output: {
comments: false,
beautify: false
}
}
}),
/**
* Plugin: NormalModuleReplacementPlugin
* Description: Replace resources that matches resourceRegExp with newResource
*
* See: http://webpack.github.io/docs/list-of-plugins.html#normalmodulereplacementplugin
*/
new NormalModuleReplacementPlugin(
/(angular2|@angularclass)((\\|\/)|-)hmr/,
helpers.root('config/empty.js')
),
new NormalModuleReplacementPlugin(
/zone\.js(\\|\/)dist(\\|\/)long-stack-trace-zone/,
helpers.root('config/empty.js')
),
new HashedModuleIdsPlugin(),
/**
* AoT
*/
(AOT ? (
new NormalModuleReplacementPlugin(
/@angular(\\|\/)compiler/,
helpers.root('config/empty.js')
)
) : (new LoaderOptionsPlugin({}))),
/**
* Plugin LoaderOptionsPlugin (experimental)
*
* See: https://gist.github.com/sokra/27b24881210b56bbaff7
*/
new LoaderOptionsPlugin({
minimize: true,
debug: false,
options: {
/**
* Static analysis linter for TypeScript advanced options configuration
* Description: An extensible linter for the TypeScript language.
*
* See: https://github.com/wbuchwalter/tslint-loader
*/
tslint: {
emitErrors: true,
failOnHint: true,
resourcePath: 'src'
},
/**
* Html loader advanced options
*
* See: https://github.com/webpack/html-loader#advanced-options
*/
// TODO: Need to workaround Angular 2's html syntax => #id [bind] (event) *ngFor
htmlLoader: {
minimize: true,
removeAttributeQuotes: false,
caseSensitive: true,
customAttrSurround: [
[/#/, /(?:)/],
[/\*/, /(?:)/],
[/\[?\(?/, /(?:)/]
],
customAttrAssign: [/\)?]?=/]
},
// FIXME: Remove
// https://github.com/bholloway/resolve-url-loader/issues/36
// https://github.com/jtangelder/sass-loader/issues/289
context: __dirname,
output: {
path: helpers.root('dist')
}
}
}),
new BundleAnalyzerPlugin({
// Can be `server`, `static` or `disabled`.
// In `server` mode analyzer will start HTTP server to show bundle report.
// In `static` mode single HTML file with bundle report will be generated.
// In `disabled` mode you can use this plugin to just generate Webpack Stats JSON file by setting `generateStatsFile` to `true`.
analyzerMode: 'static',
// Path to bundle report file that will be generated in `static` mode.
// Relative to bundles output directory.
reportFilename: 'report.html',
// Automatically open report in default browser
openAnalyzer: false,
// If `true`, Webpack Stats JSON file will be generated in bundles output directory
generateStatsFile: true,
// Name of Webpack Stats JSON file that will be generated if `generateStatsFile` is `true`.
// Relative to bundles output directory.
statsFilename: 'stats.json',
// Options for `stats.toJson()` method.
// For example you can exclude sources of your modules from stats file with `source: false` option.
// See more options here: https://github.com/webpack/webpack/blob/webpack-1/lib/Stats.js#L21
statsOptions: null,
// Log level. Can be 'info', 'warn', 'error' or 'silent'.
logLevel: 'info'
})
],
/*
* Include polyfills or mocks for various node stuff
* Description: Node configuration
*
* See: https://webpack.github.io/docs/configuration.html#node
*/
node: {
global: true,
crypto: 'empty',
fs: 'empty',
process: true,
module: false,
clearImmediate: false,
setImmediate: false
}
})
]
}

View file

@ -15,7 +15,7 @@
"scripts": {
"lint": "standard && tslint --type-check --project ./tsconfig.json -c ./tslint.json 'src/app/**/*.ts'",
"webpack": "webpack",
"webpack-dev-server<": "webpack-dev-server",
"ng": "ng",
"postinstall": "npm rebuild node-sass"
},
"license": "GPLv3",
@ -33,80 +33,45 @@
"@angular/platform-browser": "~4.4.0",
"@angular/platform-browser-dynamic": "~4.4.0",
"@angular/router": "~4.4.0",
"@angularclass/hmr": "^2.1.0",
"@angularclass/hmr-loader": "^3.0.2",
"@ngx-meta/core": "^4.0.1",
"@types/core-js": "^0.9.28",
"@types/markdown-it": "^0.0.4",
"@types/node": "^8.0.33",
"@types/source-map": "^0.5.1",
"@types/uglify-js": "^2.0.27",
"@types/video.js": "6.2.0",
"@types/webpack": "^3.0.0",
"@types/webtorrent": "^0.98.4",
"add-asset-html-webpack-plugin": "^2.0.1",
"angular2-notifications": "^0.7.7",
"angular2-template-loader": "^0.6.0",
"assets-webpack-plugin": "^3.4.0",
"awesome-typescript-loader": "3.2.3",
"babel-core": "^6.25.0",
"babel-loader": "^7.1.0",
"babel-preset-env": "^1.5.2",
"bootstrap-sass": "^3.3.7",
"codelyzer": "^3.0.0-beta.4",
"copy-webpack-plugin": "^4.0.0",
"core-js": "^2.4.1",
"css-loader": "^0.28.4",
"css-to-string-loader": "^0.1.3",
"es6-shim": "^0.35.0",
"extract-text-webpack-plugin": "^3.0.0",
"extract-text-webpack-plugin": "^3.0.2",
"file-loader": "^1.1.5",
"html-webpack-plugin": "^2.19.0",
"ie-shim": "^0.1.0",
"inline-manifest-webpack-plugin": "^3.0.1",
"intl": "^1.2.4",
"json-loader": "^0.5.4",
"markdown-it": "^8.4.0",
"ng-router-loader": "^2.0.0",
"ngc-webpack": "3.2.2",
"ngx-bootstrap": "2.0.0-beta.9",
"ngx-chips": "1.5.3",
"ngx-clipboard": "^9.0.0",
"ngx-infinite-scroll": "^0.7.0",
"ngx-pipes": "^2.0.5",
"node-sass": "^4.1.1",
"normalize.css": "^7.0.0",
"npm-font-source-sans-pro": "^1.0.2",
"optimize-js-plugin": "0.0.4",
"primeng": "^4.2.0",
"purify-css": "^1.2.5",
"purifycss-webpack": "^0.7.0",
"raw-loader": "^0.5.1",
"reflect-metadata": "^0.1.9",
"resolve-url-loader": "^2.0.0",
"rxjs": "^5.4.2",
"sass-loader": "^6.0.3",
"sass-resources-loader": "^1.2.1",
"script-ext-html-webpack-plugin": "^1.3.2",
"source-map-loader": "^0.2.1",
"standard": "^10.0.0",
"string-replace-loader": "^1.0.3",
"style-loader": "^0.19.0",
"tslib": "^1.5.0",
"tslint": "^5.7.0",
"tslint-config-standard": "^7.0.0",
"tslint-loader": "^3.3.0",
"typescript": "^2.5.2",
"uglifyjs-webpack-plugin": "^1.0.1",
"url-loader": "^0.6.2",
"uglifyjs-webpack-plugin": "^1.1.2",
"video.js": "^6.2.0",
"videojs-dock": "^2.0.2",
"webpack": "^3.3.0",
"webpack-bundle-analyzer": "^2.8.2",
"webpack-dev-server": "^2.4.5",
"webpack-dll-bundles-plugin": "^1.0.0-beta.5",
"webpack-merge": "~4.1.0",
"webpack-notifier": "^1.3.0",
"webtorrent": "^0.98.0",
"zone.js": "~0.8.5"
}

View file

@ -1,9 +1,8 @@
import { Component, OnDestroy, OnInit } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router'
import { NotificationsService } from 'angular2-notifications'
import { AbstractVideoList } from 'app/shared/video/abstract-video-list'
import { Subscription } from 'rxjs/Subscription'
import { SortField } from '../../shared/video/sort-field.type'
import { AbstractVideoList } from '../../shared/video/abstract-video-list'
import { VideoService } from '../../shared/video/video.service'
@Component({

View file

@ -1,7 +1,7 @@
import { Component, OnInit } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router'
import { NotificationsService } from 'angular2-notifications'
import { AbstractVideoList } from 'app/shared/video/abstract-video-list'
import { AbstractVideoList } from '../../shared/video/abstract-video-list'
import { SortField } from '../../shared/video/sort-field.type'
import { VideoService } from '../../shared/video/video.service'

View file

@ -1,3 +1,5 @@
@import '_variables';
@import '_mixins';
@import '~video.js/dist/video-js.css';
@import '~videojs-dock/dist/videojs-dock.css';
@import '../../sass/video-js-custom.scss';

View file

@ -1,16 +1,16 @@
switch (process.env.NODE_ENV) {
case 'prod':
case 'production':
module.exports = require('./config/webpack.prod')({env: 'production'})
module.exports = require('./webpack/webpack.prod')({env: 'production'})
break
case 'test':
case 'testing':
module.exports = require('./config/webpack.test')({env: 'test'})
module.exports = require('./webpack/webpack.test')({env: 'test'})
break
case 'dev':
case 'development':
default:
module.exports = require('./config/webpack.dev')({env: 'development'})
module.exports = require('./webpack/webpack.dev')({env: 'development'})
}

View file

@ -2,13 +2,14 @@ const helpers = require('./helpers')
const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin
const HtmlWebpackPlugin = require('html-webpack-plugin')
const UglifyJsPlugin = require('webpack/lib/optimize/UglifyJsPlugin')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const HashedModuleIdsPlugin = require('webpack/lib/HashedModuleIdsPlugin')
const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const PurifyCSSPlugin = require('purifycss-webpack')
module.exports = function (options) {
const isProd = options && options.env === 'production'
module.exports = function () {
const isProd = process.env.NODE_ENV === 'production'
const configuration = {
entry: {
@ -43,8 +44,7 @@ module.exports = function (options) {
{
loader: 'awesome-typescript-loader',
options: {
configFileName: 'tsconfig.webpack.json',
useCache: !isProd
configFileName: 'tsconfig.json'
}
}
],
@ -67,15 +67,9 @@ module.exports = function (options) {
{
loader: 'sass-loader',
options: {
sourceMap: true
}
},
{
loader: 'sass-resources-loader',
options: {
resources: [
helpers.root('src/sass/_variables.scss'),
helpers.root('src/sass/_mixins.scss')
sourceMap: true,
includePaths: [
helpers.root('src/sass/include')
]
}
}
@ -124,6 +118,20 @@ module.exports = function (options) {
title: 'PeerTube',
chunksSortMode: 'dependency',
inject: 'body'
}),
/**
* Plugin LoaderOptionsPlugin (experimental)
*
* See: https://gist.github.com/sokra/27b24881210b56bbaff7
*/
new LoaderOptionsPlugin({
options: {
context: __dirname,
output: {
path: helpers.root('dist')
}
}
})
],
@ -139,40 +147,21 @@ module.exports = function (options) {
}
if (isProd) {
configuration.module.rules.push(
{
test: /junk\/index\.js$/,
// exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: [ 'env' ]
}
}
}
)
configuration.plugins.push(
new UglifyJsPlugin({
beautify: false,
output: {
comments: false
}, // prod
mangle: {
screw_ie8: true
}, // prod
compress: {
screw_ie8: true,
uglifyOptions: {
ecma: 6,
warnings: false,
conditionals: true,
unused: true,
comparisons: true,
sequences: true,
dead_code: true,
evaluate: true,
if_return: true,
join_vars: true,
negate_iife: false // we need this for lazy v8
ie8: false,
mangle: true,
compress: {
passes: 3,
pure_getters: true
},
output: {
ascii_only: true,
comments: false
}
}
}),

File diff suppressed because it is too large Load diff

View file

@ -2,6 +2,7 @@
cd client || exit -1
rm -rf ./compiled ./dist
rm -rf ./dist
npm run webpack -- --config config/webpack.prod.js --progress --profile --bail
ng build -- --prod
NODE_ENV=production npm run webpack -- --config webpack/webpack.video-embed.js

View file

@ -2,4 +2,4 @@
cd client || exit -1
npm run webpack-dev-server -- --config config/webpack.dev.js --progress --profile --colors --watch --content-base src/ --hotOnly --open
ng server --host localhost --port 3000