]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/config/webpack.dev.js
Fix error logging
[github/Chocobozzz/PeerTube.git] / client / config / webpack.dev.js
index 964ea56a5f73384189308e7c9e2247941b1d6e0e..c472ac762f6e0f48462431645bba7cb13fa9a328 100644 (file)
@@ -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,16 +22,19 @@ 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
  *
  * See: http://webpack.github.io/docs/configuration.html#cli
  */
 module.exports = function (env) {
-  return webpackMerge(commonConfig({env: ENV}), {
+  return webpackMerge(commonConfig({ env: ENV }), {
     /**
     * Developer tool to enhance debugging
     *
@@ -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,