]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/config/webpack.common.js
Client: update tslint -> 3.15.1
[github/Chocobozzz/PeerTube.git] / client / config / webpack.common.js
index abbf84fb09ea3c2f1f5a8c30c65dfdf874081106..6edc9400c504dbfcc97828d8485cbef628eec65b 100644 (file)
@@ -5,16 +5,18 @@ const helpers = require('./helpers')
  * Webpack Plugins
  */
 
-var CopyWebpackPlugin = (CopyWebpackPlugin = require('copy-webpack-plugin'), CopyWebpackPlugin.default || CopyWebpackPlugin)
+const CopyWebpackPlugin = require('copy-webpack-plugin')
 const HtmlWebpackPlugin = require('html-webpack-plugin')
 const ForkCheckerPlugin = require('awesome-typescript-loader').ForkCheckerPlugin
+const WebpackNotifierPlugin = require('webpack-notifier')
 
 /*
  * Webpack Constants
  */
 const METADATA = {
   title: 'PeerTube',
-  baseUrl: '/'
+  baseUrl: '/',
+  isDevServer: helpers.isWebpackDevServer()
 }
 
 /*
@@ -69,7 +71,6 @@ module.exports = {
 
     // remove other default values
     modulesDirectories: [ 'node_modules' ]
-
   },
 
   output: {
@@ -89,27 +90,15 @@ module.exports = {
      */
     preLoaders: [
 
-      /*
-       * Tslint loader support for *.ts files
-       *
-       * See: https://github.com/wbuchwalter/tslint-loader
-       */
-      // { test: /\.ts$/, loader: 'tslint-loader', exclude: [ helpers.root('node_modules') ] },
-
-      /*
-       * Source map loader support for *.js files
-       * Extracts SourceMaps for source files that as added as sourceMappingURL comment.
-       *
-       * See: https://github.com/webpack/source-map-loader
-       */
       {
-        test: /\.js$/,
-        loader: 'source-map-loader',
-        exclude: [
-          // these packages have problems with their sourcemaps
-          helpers.root('node_modules/rxjs'),
-          helpers.root('node_modules/@angular')
-        ]
+        test: /\.ts$/,
+        loader: 'string-replace-loader',
+        query: {
+          search: '(System|SystemJS)(.*[\\n\\r]\\s*\\.|\\.)import\\((.+)\\)',
+          replace: '$1.import($3).then(mod => mod.__esModule ? mod.default : mod)',
+          flags: 'g'
+        },
+        include: [helpers.root('src')]
       }
 
     ],
@@ -131,7 +120,11 @@ module.exports = {
        */
       {
         test: /\.ts$/,
-        loader: 'awesome-typescript-loader',
+        loaders: [
+          'awesome-typescript-loader',
+          'angular2-template-loader',
+          '@angularclass/hmr-loader'
+        ],
         exclude: [/\.(spec|e2e)\.ts$/]
       },
 
@@ -145,12 +138,6 @@ module.exports = {
         loader: 'json-loader'
       },
 
-      /*
-       * Raw loader support for *.css files
-       * Returns file content as string
-       *
-       * See: https://github.com/webpack/raw-loader
-       */
       {
         test: /\.scss$/,
         exclude: /node_modules/,
@@ -177,6 +164,10 @@ module.exports = {
 
   },
 
+  sassLoader: {
+    precision: 10
+  },
+
   /*
    * Add additional plugins to the compiler.
    *
@@ -192,16 +183,6 @@ module.exports = {
      */
     new ForkCheckerPlugin(),
 
-    /*
-     * Plugin: OccurenceOrderPlugin
-     * Description: Varies the distribution of the ids to get the smallest id length
-     * for often used ids.
-     *
-     * See: https://webpack.github.io/docs/list-of-plugins.html#occurrenceorderplugin
-     * See: https://github.com/webpack/docs/wiki/optimization#minimize
-     */
-    new webpack.optimize.OccurenceOrderPlugin(true),
-
     /*
      * Plugin: CommonsChunkPlugin
      * Description: Shares common code between the pages.
@@ -222,10 +203,16 @@ module.exports = {
      *
      * See: https://www.npmjs.com/package/copy-webpack-plugin
      */
-    new CopyWebpackPlugin([{
-      from: 'src/assets',
-      to: 'assets'
-    }]),
+    new CopyWebpackPlugin([
+      {
+        from: 'src/assets',
+        to: 'assets'
+      },
+      {
+        from: 'node_modules/webtorrent/webtorrent.min.js',
+        to: 'assets/webtorrent'
+      }
+    ]),
 
     /*
      * Plugin: HtmlWebpackPlugin
@@ -240,12 +227,7 @@ module.exports = {
       chunksSortMode: 'dependency'
     }),
 
-    new webpack.ProvidePlugin({
-      jQuery: 'jquery',
-      $: 'jquery',
-      jquery: 'jquery'
-    })
-
+    new WebpackNotifierPlugin({ alwaysNotify: true })
   ],
 
   /*
@@ -257,6 +239,8 @@ module.exports = {
   node: {
     global: 'window',
     crypto: 'empty',
+    fs: 'empty',
+    events: true,
     module: false,
     clearImmediate: false,
     setImmediate: false