]>
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 var CopyWebpackPlugin
= (CopyWebpackPlugin
= require('copy-webpack-plugin'), CopyWebpackPlugin
.default || CopyWebpackPlugin
)
9 const HtmlWebpackPlugin
= require('html-webpack-plugin')
10 const ForkCheckerPlugin
= require('awesome-typescript-loader').ForkCheckerPlugin
11 const WebpackNotifierPlugin
= require('webpack-notifier')
22 * Webpack configuration
24 * See: http://webpack.github.io/docs/configuration.html#cli
28 * Static metadata for index.html
30 * See: (custom attribute)
35 * Cache generated modules and chunks to improve performance for multiple incremental builds.
36 * This is enabled by default in watch mode.
37 * You can pass false to disable it.
39 * See: http://webpack.github.io/docs/configuration.html#cache
44 * The entry point for the bundle
47 * See: http://webpack.github.io/docs/configuration.html#entry
50 'polyfills': './src/polyfills.ts',
51 'vendor': './src/vendor.ts',
52 'main': './src/main.ts'
56 * Options affecting the resolving of modules.
58 * See: http://webpack.github.io/docs/configuration.html#resolve
62 * An array of extensions that should be used to resolve modules.
64 * See: http://webpack.github.io/docs/configuration.html#resolve-extensions
66 extensions: [ '', '.ts', '.js', '.scss' ],
68 // Make sure root is src
69 root: helpers
.root('src'),
71 // remove other default values
72 modulesDirectories: [ 'node_modules' ],
74 packageAlias: 'browser'
79 publicPath: '/client/'
83 * Options affecting the normal modules.
85 * See: http://webpack.github.io/docs/configuration.html#module
89 * An array of applied pre and post loaders.
91 * See: http://webpack.github.io/docs/configuration.html#module-preloaders-module-postloaders
96 * Tslint loader support for *.ts files
98 * See: https://github.com/wbuchwalter/tslint-loader
100 // { test: /\.ts$/, loader: 'tslint-loader', exclude: [ helpers.root('node_modules') ] },
103 * Source map loader support for *.js files
104 * Extracts SourceMaps for source files that as added as sourceMappingURL comment.
106 * See: https://github.com/webpack/source-map-loader
110 loader: 'source-map-loader',
112 // these packages have problems with their sourcemaps
113 helpers
.root('node_modules/rxjs'),
114 helpers
.root('node_modules/@angular')
121 * An array of automatically applied loaders.
123 * IMPORTANT: The loaders here are resolved relative to the resource which they are applied to.
124 * This means they are not resolved relative to the configuration file.
126 * See: http://webpack.github.io/docs/configuration.html#module-loaders
131 * Typescript loader support for .ts and Angular 2 async routes via .async.ts
133 * See: https://github.com/s-panferov/awesome-typescript-loader
137 loader: 'awesome-typescript-loader',
138 exclude: [/\.(spec|e2e)\.ts$/]
142 * Json loader support for *.json files.
144 * See: https://github.com/webpack/json-loader
148 loader: 'json-loader'
153 exclude: /node_modules/,
154 loaders: [ 'raw-loader', 'sass-loader' ]
158 test: /\.(woff2?|ttf|eot|svg)$/,
159 loader: 'url?limit=10000&name=assets/fonts/[hash].[ext]'
162 /* Raw loader support for *.html
163 * Returns file content as string
165 * See: https://github.com/webpack/raw-loader
169 loader: 'raw-loader',
170 exclude: [ helpers
.root('src/index.html') ]
182 * Add additional plugins to the compiler.
184 * See: http://webpack.github.io/docs/configuration.html#plugins
189 * Plugin: ForkCheckerPlugin
190 * Description: Do type checking in a separate process, so webpack don't need to wait.
192 * See: https://github.com/s-panferov/awesome-typescript-loader#forkchecker-boolean-defaultfalse
194 new ForkCheckerPlugin(),
197 * Plugin: OccurenceOrderPlugin
198 * Description: Varies the distribution of the ids to get the smallest id length
199 * for often used ids.
201 * See: https://webpack.github.io/docs/list-of-plugins.html#occurrenceorderplugin
202 * See: https://github.com/webpack/docs/wiki/optimization#minimize
204 new webpack
.optimize
.OccurenceOrderPlugin(true),
207 * Plugin: CommonsChunkPlugin
208 * Description: Shares common code between the pages.
209 * It identifies common modules and put them into a commons chunk.
211 * See: https://webpack.github.io/docs/list-of-plugins.html#commonschunkplugin
212 * See: https://github.com/webpack/docs/wiki/optimization#multi-page-app
214 new webpack
.optimize
.CommonsChunkPlugin({
215 name: [ 'polyfills', 'vendor' ].reverse()
219 * Plugin: CopyWebpackPlugin
220 * Description: Copy files and directories in webpack.
222 * Copies project static assets.
224 * See: https://www.npmjs.com/package/copy-webpack-plugin
226 new CopyWebpackPlugin([
232 from: 'node_modules/webtorrent/webtorrent.min.js',
233 to: 'assets/webtorrent'
238 * Plugin: HtmlWebpackPlugin
239 * Description: Simplifies creation of HTML files to serve your webpack bundles.
240 * This is especially useful for webpack bundles that include a hash in the filename
241 * which changes every compilation.
243 * See: https://github.com/ampedandwired/html-webpack-plugin
245 new HtmlWebpackPlugin({
246 template: 'src/index.html',
247 chunksSortMode: 'dependency'
250 new WebpackNotifierPlugin({ alwaysNotify: true })
254 * Include polyfills or mocks for various node stuff
255 * Description: Node configuration
257 * See: https://webpack.github.io/docs/configuration.html#node
265 clearImmediate: false,