X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fconfig%2Fwebpack.dev.js;h=c472ac762f6e0f48462431645bba7cb13fa9a328;hb=ad0997adfb9e1e3b1ff54338d7558cf7b18440ea;hp=05475774805c930b95ceaef7ac9bb06972c3b19a;hpb=9bce75925eb972f7a49c25250e636b7b76734475;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/config/webpack.dev.js b/client/config/webpack.dev.js index 054757748..c472ac762 100644 --- a/client/config/webpack.dev.js +++ b/client/config/webpack.dev.js @@ -1,10 +1,12 @@ 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 /** * 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') @@ -20,9 +22,12 @@ const METADATA = webpackMerge(commonConfig({env: ENV}).metadata, { host: HOST, port: PORT, ENV: ENV, - HMR: HMR + HMR: HMR, + API_URL: 'http://localhost:9000' }) +const DllBundlesPlugin = require('webpack-dll-bundles-plugin').DllBundlesPlugin + /** * Webpack configuration * @@ -75,13 +80,29 @@ module.exports = function (env) { chunkFilename: '[id].chunk.js', library: 'ac_[name]', - libraryTarget: 'var', - - publicPath: '/client/' + libraryTarget: 'var' }, - externals: { - webtorrent: 'WebTorrent' + module: { + + // Too slow, life is short + // rules: [ + // { + // test: /\.ts$/, + // use: [ + // { + // loader: 'tslint-loader', + // options: { + // configFile: 'tslint.json' + // } + // } + // ], + // exclude: [ + // /\.(spec|e2e)\.ts$/, + // /node_modules\// + // ] + // } + // ] }, plugins: [ @@ -99,6 +120,8 @@ module.exports = function (env) { 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), 'NODE_ENV': JSON.stringify(METADATA.ENV), @@ -106,6 +129,51 @@ module.exports = function (env) { } }), + 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. @@ -132,6 +200,7 @@ module.exports = function (env) { tslint: { emitErrors: false, failOnHint: false, + typeCheck: true, resourcePath: 'src' }, @@ -161,10 +230,8 @@ module.exports = function (env) { host: METADATA.host, historyApiFallback: true, watchOptions: { - aggregateTimeout: 300, - poll: 1000 - }, - outputPath: helpers.root('dist') + ignored: /node_modules/ + } }, /* @@ -176,6 +243,7 @@ module.exports = function (env) { node: { global: true, crypto: 'empty', + fs: 'empty', process: true, module: false, clearImmediate: false,