]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/webpack/webpack.video-embed.js
Update translations
[github/Chocobozzz/PeerTube.git] / client / webpack / webpack.video-embed.js
CommitLineData
202e7223 1const helpers = require('./helpers')
6cca7360 2const path = require('path')
202e7223 3
202e7223 4const HtmlWebpackPlugin = require('html-webpack-plugin')
ae04a0ce 5const TerserPlugin = require('terser-webpack-plugin')
662351e6 6const ProvidePlugin = require('webpack/lib/ProvidePlugin')
4f926722 7const MiniCssExtractPlugin = require('mini-css-extract-plugin')
202e7223 8
7bfd1b1e 9module.exports = function () {
202e7223
C
10 const configuration = {
11 entry: {
99941732
WL
12 'video-embed': './src/standalone/videos/embed.ts',
13 'player': './src/standalone/player/player.ts',
14 'test-embed': './src/standalone/videos/test-embed.ts'
202e7223
C
15 },
16
17 resolve: {
18 /*
19 * An array of extensions that should be used to resolve modules.
20 *
21 * See: http://webpack.github.io/docs/configuration.html#resolve-extensions
22 */
23 extensions: [ '.ts', '.js', '.json', '.scss' ],
24
72aa835e 25 modules: [ helpers.root('src'), 'node_modules' ],
6cca7360 26
a77c5ff3
C
27 symlinks: true,
28
6cca7360 29 alias: {
71ab65d0 30 'video.js$': path.resolve('node_modules/video.js/core.js'),
134006b0 31 'hls.js$': path.resolve('node_modules/hls.js/dist/hls.light.js'),
4504f09f 32 '@root-helpers': path.resolve('src/root-helpers'),
583eb04b 33 '@shared/models': path.resolve('../shared/models'),
bd45d503 34 '@shared/core-utils': path.resolve('../shared/core-utils')
662351e6
C
35 },
36
37 fallback: {
38 fs: [ path.resolve('src/shims/noop.ts') ],
39 http: [ path.resolve('src/shims/http.ts') ],
40 https: [ path.resolve('src/shims/https.ts') ],
41 path: [ path.resolve('src/shims/path.ts') ],
134006b0 42 stream: [ path.resolve('src/shims/stream.ts') ],
662351e6 43 crypto: [ path.resolve('src/shims/noop.ts') ]
6cca7360 44 }
202e7223
C
45 },
46
47 output: {
48 path: helpers.root('dist/standalone/videos'),
a3b5e78a
C
49
50 filename: process.env.ANALYZE_BUNDLE === 'true'
51 ? '[name].bundle.js'
662351e6 52 : '[name].[contenthash].bundle.js',
a3b5e78a 53
202e7223 54 sourceMapFilename: '[file].map',
031ea8ef
C
55
56 chunkFilename: process.env.ANALYZE_BUNDLE === 'true'
57 ? '[name].chunk.js'
662351e6 58 : '[id].[contenthash].chunk.js',
031ea8ef 59
202e7223
C
60 publicPath: '/client/standalone/videos/'
61 },
62
d1a63fc7 63 devtool: process.env.NODE_ENV === 'production' ? false : 'source-map',
f6a7c82c 64
202e7223
C
65 module: {
66
67 rules: [
68 {
69 test: /\.ts$/,
70 use: [
39a88d24
C
71 getBabelLoader(),
72
202e7223 73 {
583eb04b 74 loader: 'ts-loader',
202e7223 75 options: {
42b40636 76 configFile: helpers.root('src/standalone/videos/tsconfig.json')
202e7223
C
77 }
78 }
583eb04b 79 ]
202e7223 80 },
6527eb0c 81 {
4ce5f50c 82 test: /\.m?js$/,
39a88d24 83 use: [ getBabelLoader() ]
6527eb0c 84 },
202e7223
C
85
86 {
87 test: /\.(sass|scss)$/,
4f926722
C
88 use: [
89 MiniCssExtractPlugin.loader,
90
91 {
92 loader: 'css-loader',
93 options: {
94 sourceMap: true,
95 importLoaders: 1
96 }
97 },
98
99 {
100 loader: 'sass-loader',
101 options: {
102 sassOptions: {
202e7223 103 sourceMap: true,
4f926722
C
104 includePaths: [
105 helpers.root('src/sass/include')
106 ]
202e7223
C
107 }
108 }
4f926722
C
109 }
110 ]
202e7223
C
111 },
112
113 {
114 test: /\.html$/,
202e7223
C
115 exclude: [
116 helpers.root('src/index.html'),
99941732
WL
117 helpers.root('src/standalone/videos/embed.html'),
118 helpers.root('src/standalone/videos/test-embed.html')
adb8809d
C
119 ],
120 type: 'asset/source'
202e7223
C
121 },
122
123 {
adb8809d
C
124 test: /\.(jpg|png|gif|svg)$/,
125 type: 'asset'
202e7223
C
126 },
127
adb8809d
C
128 {
129 test: /\.(ttf|eot|woff2?)$/,
130 type: 'asset'
131 }
202e7223
C
132 ]
133
134 },
135
136 plugins: [
662351e6
C
137 new ProvidePlugin({
138 process: 'process/browser',
139 Buffer: [ 'buffer', 'Buffer' ]
140 }),
141
4f926722 142 new MiniCssExtractPlugin({
a3b5e78a
C
143 filename: process.env.ANALYZE_BUNDLE === 'true'
144 ? '[name].css'
662351e6 145 : '[name].[contenthash].css'
202e7223
C
146 }),
147
202e7223
C
148 new HtmlWebpackPlugin({
149 template: 'src/standalone/videos/embed.html',
150 filename: 'embed.html',
151 title: 'PeerTube',
4adebd51 152 chunksSortMode: 'auto',
99941732 153 inject: 'body',
662351e6 154 chunks: [ 'video-embed' ],
2564d97e 155 minify: {
156 collapseWhitespace: true,
157 removeComments: false,
158 removeRedundantAttributes: true,
159 removeScriptTypeAttributes: true,
160 removeStyleLinkTypeAttributes: true,
161 useShortDoctype: true
162 }
99941732
WL
163 }),
164
165 new HtmlWebpackPlugin({
166 template: '!!html-loader!src/standalone/videos/test-embed.html',
167 filename: 'test-embed.html',
168 title: 'PeerTube',
4adebd51 169 chunksSortMode: 'auto',
99941732 170 inject: 'body',
662351e6 171 chunks: [ 'test-embed' ]
202e7223
C
172 })
173 ],
174
ae04a0ce
C
175 optimization: {
176 minimizer: [
177 new TerserPlugin({
178 terserOptions: {
179 ecma: 6,
180 warnings: false,
181 ie8: false,
92a6e85f 182 safari10: false,
ae04a0ce
C
183 mangle: true,
184 compress: {
185 passes: 3,
186 pure_getters: true
187 },
188 output: {
189 ascii_only: true,
190 comments: false
191 }
192 }
193 })
194 ]
195 },
196
fc9e6624 197 performance: {
efda99c3
C
198 maxEntrypointSize: 700000, // 600kB
199 maxAssetSize: 700000
fc9e6624
C
200 },
201
202e7223 202 node: {
662351e6 203 global: true
202e7223
C
204 }
205 }
206
202e7223
C
207 return configuration
208}
39a88d24
C
209
210function getBabelLoader () {
211 return {
212 loader: 'babel-loader',
213 options: {
214 presets: [
215 [
216 '@babel/preset-env', {
92a6e85f 217 targets: 'last 1 Chrome version, last 2 Edge major versions, Firefox ESR, Safari >= 12, ios_saf >= 12'
39a88d24
C
218 }
219 ]
220 ]
221 }
222 }
223}