]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/config/webpack.dev.js
Client: update a webpack configs
[github/Chocobozzz/PeerTube.git] / client / config / webpack.dev.js
index 02e9857f727b0cd1cd03428d8174604c08cbea0c..5e4c708d67426f6353acba1d7f2d29ffa38d77a2 100644 (file)
@@ -6,15 +6,18 @@ const commonConfig = require('./webpack.common.js') // the settings that are com
  * Webpack Plugins
  */
 const DefinePlugin = require('webpack/lib/DefinePlugin')
+const NamedModulesPlugin = require('webpack/lib/NamedModulesPlugin')
 
 /**
  * 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 HMR = helpers.hasProcessFlag('hot')
-const METADATA = webpackMerge(commonConfig.metadata, {
-  host: 'localhost',
-  port: 3000,
+const METADATA = webpackMerge(commonConfig({env: ENV}).metadata, {
+  host: HOST,
+  port: PORT,
   ENV: ENV,
   HMR: HMR
 })
@@ -24,7 +27,7 @@ const METADATA = webpackMerge(commonConfig.metadata, {
  *
  * See: http://webpack.github.io/docs/configuration.html#cli
  */
-module.exports = webpackMerge(commonConfig, {
+module.exports = webpackMerge(commonConfig({env: ENV}), {
   /**
    * Merged metadata from webpack.common.js for index.html
    *
@@ -81,8 +84,15 @@ module.exports = webpackMerge(commonConfig, {
      *
      * See: http://webpack.github.io/docs/configuration.html#output-chunkfilename
      */
-    chunkFilename: '[id].chunk.js'
+    chunkFilename: '[id].chunk.js',
 
+    library: 'ac_[name]',
+    libraryTarget: 'var'
+
+  },
+
+  externals: {
+    webtorrent: 'WebTorrent'
   },
 
   plugins: [
@@ -105,7 +115,9 @@ module.exports = webpackMerge(commonConfig, {
         'NODE_ENV': JSON.stringify(METADATA.ENV),
         'HMR': METADATA.HMR
       }
-    })
+    }),
+
+    new NamedModulesPlugin()
   ],
 
   /**
@@ -120,14 +132,6 @@ module.exports = webpackMerge(commonConfig, {
     resourcePath: 'src'
   },
 
-  /**
-   * 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,