]>
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
21 * Webpack configuration
23 * See: http://webpack.github.io/docs/configuration.html#cli
27 * Static metadata for index.html
29 * See: (custom attribute)
34 * Cache generated modules and chunks to improve performance for multiple incremental builds.
35 * This is enabled by default in watch mode.
36 * You can pass false to disable it.
38 * See: http://webpack.github.io/docs/configuration.html#cache
43 * The entry point for the bundle
46 * See: http://webpack.github.io/docs/configuration.html#entry
49 'polyfills': './src/polyfills.ts',
50 'vendor': './src/vendor.ts',
51 'main': './src/main.ts'
55 * Options affecting the resolving of modules.
57 * See: http://webpack.github.io/docs/configuration.html#resolve
61 * An array of extensions that should be used to resolve modules.
63 * See: http://webpack.github.io/docs/configuration.html#resolve-extensions
65 extensions: [ '', '.ts', '.js', '.scss' ],
67 // Make sure root is src
68 root: helpers
.root('src'),
70 // remove other default values
71 modulesDirectories: [ 'node_modules', 'node_modules/blueimp-file-upload/js/vendor' ],
73 packageAlias: 'browser'
78 publicPath: '/client/'
82 * Options affecting the normal modules.
84 * See: http://webpack.github.io/docs/configuration.html#module
88 * An array of applied pre and post loaders.
90 * See: http://webpack.github.io/docs/configuration.html#module-preloaders-module-postloaders
95 * Tslint loader support for *.ts files
97 * See: https://github.com/wbuchwalter/tslint-loader
99 // { test: /\.ts$/, loader: 'tslint-loader', exclude: [ helpers.root('node_modules') ] },
102 * Source map loader support for *.js files
103 * Extracts SourceMaps for source files that as added as sourceMappingURL comment.
105 * See: https://github.com/webpack/source-map-loader
109 loader: 'source-map-loader',
111 // these packages have problems with their sourcemaps
112 helpers
.root('node_modules/rxjs'),
113 helpers
.root('node_modules/@angular')
120 * An array of automatically applied loaders.
122 * IMPORTANT: The loaders here are resolved relative to the resource which they are applied to.
123 * This means they are not resolved relative to the configuration file.
125 * See: http://webpack.github.io/docs/configuration.html#module-loaders
130 * Typescript loader support for .ts and Angular 2 async routes via .async.ts
132 * See: https://github.com/s-panferov/awesome-typescript-loader
136 loader: 'awesome-typescript-loader',
137 exclude: [/\.(spec|e2e)\.ts$/]
141 * Json loader support for *.json files.
143 * See: https://github.com/webpack/json-loader
147 loader: 'json-loader'
152 exclude: /node_modules/,
153 loaders: [ 'raw-loader', 'sass-loader' ]
157 test: /\.(woff2?|ttf|eot|svg)$/,
158 loader: 'url?limit=10000&name=assets/fonts/[hash].[ext]'
161 /* Raw loader support for *.html
162 * Returns file content as string
164 * See: https://github.com/webpack/raw-loader
168 loader: 'raw-loader',
169 exclude: [ helpers
.root('src/index.html') ]
177 * Add additional plugins to the compiler.
179 * See: http://webpack.github.io/docs/configuration.html#plugins
184 * Plugin: ForkCheckerPlugin
185 * Description: Do type checking in a separate process, so webpack don't need to wait.
187 * See: https://github.com/s-panferov/awesome-typescript-loader#forkchecker-boolean-defaultfalse
189 new ForkCheckerPlugin(),
192 * Plugin: OccurenceOrderPlugin
193 * Description: Varies the distribution of the ids to get the smallest id length
194 * for often used ids.
196 * See: https://webpack.github.io/docs/list-of-plugins.html#occurrenceorderplugin
197 * See: https://github.com/webpack/docs/wiki/optimization#minimize
199 new webpack
.optimize
.OccurenceOrderPlugin(true),
202 * Plugin: CommonsChunkPlugin
203 * Description: Shares common code between the pages.
204 * It identifies common modules and put them into a commons chunk.
206 * See: https://webpack.github.io/docs/list-of-plugins.html#commonschunkplugin
207 * See: https://github.com/webpack/docs/wiki/optimization#multi-page-app
209 new webpack
.optimize
.CommonsChunkPlugin({
210 name: [ 'polyfills', 'vendor' ].reverse()
214 * Plugin: CopyWebpackPlugin
215 * Description: Copy files and directories in webpack.
217 * Copies project static assets.
219 * See: https://www.npmjs.com/package/copy-webpack-plugin
221 new CopyWebpackPlugin([{
227 * Plugin: HtmlWebpackPlugin
228 * Description: Simplifies creation of HTML files to serve your webpack bundles.
229 * This is especially useful for webpack bundles that include a hash in the filename
230 * which changes every compilation.
232 * See: https://github.com/ampedandwired/html-webpack-plugin
234 new HtmlWebpackPlugin({
235 template: 'src/index.html',
236 chunksSortMode: 'dependency'
239 new webpack
.ProvidePlugin({
243 WebTorrent: 'webtorrent/webtorrent.min'
249 * Include polyfills or mocks for various node stuff
250 * Description: Node configuration
252 * See: https://webpack.github.io/docs/configuration.html#node
260 clearImmediate: false,