]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/webpack/webpack.video-embed.js
Remove unused webpack plugin
[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
C
26
27 alias: {
71ab65d0 28 'video.js$': path.resolve('node_modules/video.js/core.js'),
134006b0 29 'hls.js$': path.resolve('node_modules/hls.js/dist/hls.light.js'),
4504f09f 30 '@root-helpers': path.resolve('src/root-helpers'),
583eb04b 31 '@shared/models': path.resolve('../shared/models'),
bd45d503 32 '@shared/core-utils': path.resolve('../shared/core-utils')
662351e6
C
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') ],
134006b0 40 stream: [ path.resolve('src/shims/stream.ts') ],
662351e6 41 crypto: [ path.resolve('src/shims/noop.ts') ]
6cca7360 42 }
202e7223
C
43 },
44
45 output: {
46 path: helpers.root('dist/standalone/videos'),
a3b5e78a
C
47
48 filename: process.env.ANALYZE_BUNDLE === 'true'
49 ? '[name].bundle.js'
662351e6 50 : '[name].[contenthash].bundle.js',
a3b5e78a 51
202e7223 52 sourceMapFilename: '[file].map',
031ea8ef
C
53
54 chunkFilename: process.env.ANALYZE_BUNDLE === 'true'
55 ? '[name].chunk.js'
662351e6 56 : '[id].[contenthash].chunk.js',
031ea8ef 57
202e7223
C
58 publicPath: '/client/standalone/videos/'
59 },
60
d1a63fc7 61 devtool: process.env.NODE_ENV === 'production' ? false : 'source-map',
f6a7c82c 62
202e7223
C
63 module: {
64
65 rules: [
66 {
67 test: /\.ts$/,
68 use: [
69 {
583eb04b 70 loader: 'ts-loader',
202e7223 71 options: {
1d4591fd 72 configFile: 'tsconfig.json'
202e7223
C
73 }
74 }
583eb04b 75 ]
202e7223
C
76 },
77
78 {
79 test: /\.(sass|scss)$/,
4f926722
C
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: {
202e7223 95 sourceMap: true,
4f926722
C
96 includePaths: [
97 helpers.root('src/sass/include')
98 ]
202e7223
C
99 }
100 }
4f926722
C
101 }
102 ]
202e7223
C
103 },
104
105 {
106 test: /\.html$/,
202e7223
C
107 exclude: [
108 helpers.root('src/index.html'),
99941732
WL
109 helpers.root('src/standalone/videos/embed.html'),
110 helpers.root('src/standalone/videos/test-embed.html')
adb8809d
C
111 ],
112 type: 'asset/source'
202e7223
C
113 },
114
115 {
adb8809d
C
116 test: /\.(jpg|png|gif|svg)$/,
117 type: 'asset'
202e7223
C
118 },
119
adb8809d
C
120 {
121 test: /\.(ttf|eot|woff2?)$/,
122 type: 'asset'
123 }
202e7223
C
124 ]
125
126 },
127
128 plugins: [
662351e6
C
129 new ProvidePlugin({
130 process: 'process/browser',
131 Buffer: [ 'buffer', 'Buffer' ]
132 }),
133
4f926722 134 new MiniCssExtractPlugin({
a3b5e78a
C
135 filename: process.env.ANALYZE_BUNDLE === 'true'
136 ? '[name].css'
662351e6 137 : '[name].[contenthash].css'
202e7223
C
138 }),
139
202e7223
C
140 new HtmlWebpackPlugin({
141 template: 'src/standalone/videos/embed.html',
142 filename: 'embed.html',
143 title: 'PeerTube',
4adebd51 144 chunksSortMode: 'auto',
99941732 145 inject: 'body',
662351e6 146 chunks: [ 'video-embed' ],
2564d97e 147 minify: {
148 collapseWhitespace: true,
149 removeComments: false,
150 removeRedundantAttributes: true,
151 removeScriptTypeAttributes: true,
152 removeStyleLinkTypeAttributes: true,
153 useShortDoctype: true
154 }
99941732
WL
155 }),
156
157 new HtmlWebpackPlugin({
158 template: '!!html-loader!src/standalone/videos/test-embed.html',
159 filename: 'test-embed.html',
160 title: 'PeerTube',
4adebd51 161 chunksSortMode: 'auto',
99941732 162 inject: 'body',
662351e6 163 chunks: [ 'test-embed' ]
202e7223
C
164 })
165 ],
166
ae04a0ce
C
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
fc9e6624 188 performance: {
efda99c3
C
189 maxEntrypointSize: 700000, // 600kB
190 maxAssetSize: 700000
fc9e6624
C
191 },
192
202e7223 193 node: {
662351e6 194 global: true
202e7223
C
195 }
196 }
197
202e7223
C
198 return configuration
199}