]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/webpack/webpack.video-embed.js
Remove unused webpack plugin
[github/Chocobozzz/PeerTube.git] / client / webpack / webpack.video-embed.js
1 const helpers = require('./helpers')
2 const path = require('path')
3
4 const HtmlWebpackPlugin = require('html-webpack-plugin')
5 const TerserPlugin = require('terser-webpack-plugin')
6 const ProvidePlugin = require('webpack/lib/ProvidePlugin')
7 const MiniCssExtractPlugin = require('mini-css-extract-plugin')
8
9 module.exports = function () {
10 const configuration = {
11 entry: {
12 'video-embed': './src/standalone/videos/embed.ts',
13 'player': './src/standalone/player/player.ts',
14 'test-embed': './src/standalone/videos/test-embed.ts'
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
25 modules: [ helpers.root('src'), 'node_modules' ],
26
27 alias: {
28 'video.js$': path.resolve('node_modules/video.js/core.js'),
29 'hls.js$': path.resolve('node_modules/hls.js/dist/hls.light.js'),
30 '@root-helpers': path.resolve('src/root-helpers'),
31 '@shared/models': path.resolve('../shared/models'),
32 '@shared/core-utils': path.resolve('../shared/core-utils')
33 },
34
35 fallback: {
36 fs: [ path.resolve('src/shims/noop.ts') ],
37 http: [ path.resolve('src/shims/http.ts') ],
38 https: [ path.resolve('src/shims/https.ts') ],
39 path: [ path.resolve('src/shims/path.ts') ],
40 stream: [ path.resolve('src/shims/stream.ts') ],
41 crypto: [ path.resolve('src/shims/noop.ts') ]
42 }
43 },
44
45 output: {
46 path: helpers.root('dist/standalone/videos'),
47
48 filename: process.env.ANALYZE_BUNDLE === 'true'
49 ? '[name].bundle.js'
50 : '[name].[contenthash].bundle.js',
51
52 sourceMapFilename: '[file].map',
53
54 chunkFilename: process.env.ANALYZE_BUNDLE === 'true'
55 ? '[name].chunk.js'
56 : '[id].[contenthash].chunk.js',
57
58 publicPath: '/client/standalone/videos/'
59 },
60
61 devtool: process.env.NODE_ENV === 'production' ? false : 'source-map',
62
63 module: {
64
65 rules: [
66 {
67 test: /\.ts$/,
68 use: [
69 {
70 loader: 'ts-loader',
71 options: {
72 configFile: 'tsconfig.json'
73 }
74 }
75 ]
76 },
77
78 {
79 test: /\.(sass|scss)$/,
80 use: [
81 MiniCssExtractPlugin.loader,
82
83 {
84 loader: 'css-loader',
85 options: {
86 sourceMap: true,
87 importLoaders: 1
88 }
89 },
90
91 {
92 loader: 'sass-loader',
93 options: {
94 sassOptions: {
95 sourceMap: true,
96 includePaths: [
97 helpers.root('src/sass/include')
98 ]
99 }
100 }
101 }
102 ]
103 },
104
105 {
106 test: /\.html$/,
107 exclude: [
108 helpers.root('src/index.html'),
109 helpers.root('src/standalone/videos/embed.html'),
110 helpers.root('src/standalone/videos/test-embed.html')
111 ],
112 type: 'asset/source'
113 },
114
115 {
116 test: /\.(jpg|png|gif|svg)$/,
117 type: 'asset'
118 },
119
120 {
121 test: /\.(ttf|eot|woff2?)$/,
122 type: 'asset'
123 }
124 ]
125
126 },
127
128 plugins: [
129 new ProvidePlugin({
130 process: 'process/browser',
131 Buffer: [ 'buffer', 'Buffer' ]
132 }),
133
134 new MiniCssExtractPlugin({
135 filename: process.env.ANALYZE_BUNDLE === 'true'
136 ? '[name].css'
137 : '[name].[contenthash].css'
138 }),
139
140 new HtmlWebpackPlugin({
141 template: 'src/standalone/videos/embed.html',
142 filename: 'embed.html',
143 title: 'PeerTube',
144 chunksSortMode: 'auto',
145 inject: 'body',
146 chunks: [ 'video-embed' ],
147 minify: {
148 collapseWhitespace: true,
149 removeComments: false,
150 removeRedundantAttributes: true,
151 removeScriptTypeAttributes: true,
152 removeStyleLinkTypeAttributes: true,
153 useShortDoctype: true
154 }
155 }),
156
157 new HtmlWebpackPlugin({
158 template: '!!html-loader!src/standalone/videos/test-embed.html',
159 filename: 'test-embed.html',
160 title: 'PeerTube',
161 chunksSortMode: 'auto',
162 inject: 'body',
163 chunks: [ 'test-embed' ]
164 })
165 ],
166
167 optimization: {
168 minimizer: [
169 new TerserPlugin({
170 terserOptions: {
171 ecma: 6,
172 warnings: false,
173 ie8: false,
174 mangle: true,
175 compress: {
176 passes: 3,
177 pure_getters: true
178 },
179 output: {
180 ascii_only: true,
181 comments: false
182 }
183 }
184 })
185 ]
186 },
187
188 performance: {
189 maxEntrypointSize: 700000, // 600kB
190 maxAssetSize: 700000
191 },
192
193 node: {
194 global: true
195 }
196 }
197
198 return configuration
199 }