]>
git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/config/webpack.common.js
1 const webpack
= require('webpack')
2 const helpers
= require('./helpers')
8 const CopyWebpackPlugin
= require('copy-webpack-plugin')
9 const HtmlWebpackPlugin
= require('html-webpack-plugin')
10 const ForkCheckerPlugin
= require('awesome-typescript-loader').ForkCheckerPlugin
11 const WebpackNotifierPlugin
= require('webpack-notifier')
19 isDevServer: helpers
.isWebpackDevServer()
23 * Webpack configuration
25 * See: http://webpack.github.io/docs/configuration.html#cli
29 * Static metadata for index.html
31 * See: (custom attribute)
36 * Cache generated modules and chunks to improve performance for multiple incremental builds.
37 * This is enabled by default in watch mode.
38 * You can pass false to disable it.
40 * See: http://webpack.github.io/docs/configuration.html#cache
45 * The entry point for the bundle
48 * See: http://webpack.github.io/docs/configuration.html#entry
51 'polyfills': './src/polyfills.ts',
52 'vendor': './src/vendor.ts',
53 'main': './src/main.ts'
57 * Options affecting the resolving of modules.
59 * See: http://webpack.github.io/docs/configuration.html#resolve
63 * An array of extensions that should be used to resolve modules.
65 * See: http://webpack.github.io/docs/configuration.html#resolve-extensions
67 extensions: [ '', '.ts', '.js', '.scss' ],
69 // Make sure root is src
70 root: helpers
.root('src'),
72 // remove other default values
73 modulesDirectories: [ 'node_modules' ]
77 publicPath: '/client/'
81 * Options affecting the normal modules.
83 * See: http://webpack.github.io/docs/configuration.html#module
87 * An array of applied pre and post loaders.
89 * See: http://webpack.github.io/docs/configuration.html#module-preloaders-module-postloaders
95 loader: 'string-replace-loader',
97 search: '(System|SystemJS)(.*[\\n\\r]\\s*\\.|\\.)import\\((.+)\\)',
98 replace: '$1.import($3).then(mod => mod.__esModule ? mod.default : mod)',
101 include: [helpers
.root('src')]
107 * An array of automatically applied loaders.
109 * IMPORTANT: The loaders here are resolved relative to the resource which they are applied to.
110 * This means they are not resolved relative to the configuration file.
112 * See: http://webpack.github.io/docs/configuration.html#module-loaders
117 * Typescript loader support for .ts and Angular 2 async routes via .async.ts
119 * See: https://github.com/s-panferov/awesome-typescript-loader
124 'awesome-typescript-loader',
125 'angular2-template-loader',
126 '@angularclass/hmr-loader'
128 exclude: [/\.(spec|e2e)\.ts$/]
132 * Json loader support for *.json files.
134 * See: https://github.com/webpack/json-loader
138 loader: 'json-loader'
143 exclude: /node_modules/,
144 loaders: [ 'raw-loader', 'sass-loader' ]
148 test: /\.(woff2?|ttf|eot|svg)$/,
149 loader: 'url?limit=10000&name=assets/fonts/[hash].[ext]'
152 /* Raw loader support for *.html
153 * Returns file content as string
155 * See: https://github.com/webpack/raw-loader
159 loader: 'raw-loader',
160 exclude: [ helpers
.root('src/index.html') ]
172 * Add additional plugins to the compiler.
174 * See: http://webpack.github.io/docs/configuration.html#plugins
179 * Plugin: ForkCheckerPlugin
180 * Description: Do type checking in a separate process, so webpack don't need to wait.
182 * See: https://github.com/s-panferov/awesome-typescript-loader#forkchecker-boolean-defaultfalse
184 new ForkCheckerPlugin(),
187 * Plugin: CommonsChunkPlugin
188 * Description: Shares common code between the pages.
189 * It identifies common modules and put them into a commons chunk.
191 * See: https://webpack.github.io/docs/list-of-plugins.html#commonschunkplugin
192 * See: https://github.com/webpack/docs/wiki/optimization#multi-page-app
194 new webpack
.optimize
.CommonsChunkPlugin({
195 name: [ 'polyfills', 'vendor' ].reverse()
199 * Plugin: CopyWebpackPlugin
200 * Description: Copy files and directories in webpack.
202 * Copies project static assets.
204 * See: https://www.npmjs.com/package/copy-webpack-plugin
206 new CopyWebpackPlugin([
212 from: 'node_modules/webtorrent/webtorrent.min.js',
213 to: 'assets/webtorrent'
218 * Plugin: HtmlWebpackPlugin
219 * Description: Simplifies creation of HTML files to serve your webpack bundles.
220 * This is especially useful for webpack bundles that include a hash in the filename
221 * which changes every compilation.
223 * See: https://github.com/ampedandwired/html-webpack-plugin
225 new HtmlWebpackPlugin({
226 template: 'src/index.html',
227 chunksSortMode: 'dependency'
230 new WebpackNotifierPlugin({ alwaysNotify: true })
234 * Include polyfills or mocks for various node stuff
235 * Description: Node configuration
237 * See: https://webpack.github.io/docs/configuration.html#node
245 clearImmediate: false,