]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/webpack/webpack.video-embed.js
Clearer nsfw "do not list" label
[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')
7bfd1b1e 6const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin')
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'),
4504f09f 29 '@root-helpers': path.resolve('src/root-helpers'),
583eb04b 30 '@shared/models': path.resolve('../shared/models'),
bd45d503 31 '@shared/core-utils': path.resolve('../shared/core-utils')
6cca7360 32 }
202e7223
C
33 },
34
35 output: {
36 path: helpers.root('dist/standalone/videos'),
a3b5e78a
C
37
38 filename: process.env.ANALYZE_BUNDLE === 'true'
39 ? '[name].bundle.js'
40 : '[name].[hash].bundle.js',
41
202e7223 42 sourceMapFilename: '[file].map',
031ea8ef
C
43
44 chunkFilename: process.env.ANALYZE_BUNDLE === 'true'
45 ? '[name].chunk.js'
46 : '[id].[hash].chunk.js',
47
202e7223
C
48 publicPath: '/client/standalone/videos/'
49 },
50
d1a63fc7 51 devtool: process.env.NODE_ENV === 'production' ? false : 'source-map',
f6a7c82c 52
202e7223
C
53 module: {
54
55 rules: [
56 {
57 test: /\.ts$/,
58 use: [
59 {
583eb04b 60 loader: 'ts-loader',
202e7223 61 options: {
583eb04b 62 configFile: 'tsconfig.base.json'
202e7223
C
63 }
64 }
583eb04b 65 ]
202e7223
C
66 },
67
68 {
69 test: /\.(sass|scss)$/,
4f926722
C
70 use: [
71 MiniCssExtractPlugin.loader,
72
73 {
74 loader: 'css-loader',
75 options: {
76 sourceMap: true,
77 importLoaders: 1
78 }
79 },
80
81 {
82 loader: 'sass-loader',
83 options: {
84 sassOptions: {
202e7223 85 sourceMap: true,
4f926722
C
86 includePaths: [
87 helpers.root('src/sass/include')
88 ]
202e7223
C
89 }
90 }
4f926722
C
91 }
92 ]
202e7223
C
93 },
94
95 {
96 test: /\.html$/,
97 use: 'raw-loader',
98 exclude: [
99 helpers.root('src/index.html'),
99941732
WL
100 helpers.root('src/standalone/videos/embed.html'),
101 helpers.root('src/standalone/videos/test-embed.html')
202e7223
C
102 ]
103 },
104
105 {
106 test: /\.(jpg|png|gif)$/,
107 use: 'url-loader'
108 },
109
110 { test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, use: 'url-loader?limit=10000&minetype=application/font-woff' },
111 { test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, use: 'file-loader' }
112 ]
113
114 },
115
116 plugins: [
4f926722 117 new MiniCssExtractPlugin({
a3b5e78a
C
118 filename: process.env.ANALYZE_BUNDLE === 'true'
119 ? '[name].css'
120 : '[name].[hash].css'
202e7223
C
121 }),
122
202e7223
C
123 new HtmlWebpackPlugin({
124 template: 'src/standalone/videos/embed.html',
125 filename: 'embed.html',
126 title: 'PeerTube',
4adebd51 127 chunksSortMode: 'auto',
99941732 128 inject: 'body',
2564d97e 129 chunks: ['video-embed'],
130 minify: {
131 collapseWhitespace: true,
132 removeComments: false,
133 removeRedundantAttributes: true,
134 removeScriptTypeAttributes: true,
135 removeStyleLinkTypeAttributes: true,
136 useShortDoctype: true
137 }
99941732
WL
138 }),
139
140 new HtmlWebpackPlugin({
141 template: '!!html-loader!src/standalone/videos/test-embed.html',
142 filename: 'test-embed.html',
143 title: 'PeerTube',
4adebd51 144 chunksSortMode: 'auto',
99941732
WL
145 inject: 'body',
146 chunks: ['test-embed']
7bfd1b1e
C
147 }),
148
149 /**
150 * Plugin LoaderOptionsPlugin (experimental)
151 *
152 * See: https://gist.github.com/sokra/27b24881210b56bbaff7
153 */
154 new LoaderOptionsPlugin({
155 options: {
156 context: __dirname,
157 output: {
158 path: helpers.root('dist')
159 }
160 }
202e7223
C
161 })
162 ],
163
ae04a0ce
C
164 optimization: {
165 minimizer: [
166 new TerserPlugin({
167 terserOptions: {
168 ecma: 6,
169 warnings: false,
170 ie8: false,
171 mangle: true,
172 compress: {
173 passes: 3,
174 pure_getters: true
175 },
176 output: {
177 ascii_only: true,
178 comments: false
179 }
180 }
181 })
182 ]
183 },
184
fc9e6624 185 performance: {
efda99c3
C
186 maxEntrypointSize: 700000, // 600kB
187 maxAssetSize: 700000
fc9e6624
C
188 },
189
202e7223
C
190 node: {
191 global: true,
192 crypto: 'empty',
193 fs: 'empty',
194 process: true,
195 module: false,
196 clearImmediate: false,
197 setImmediate: false
198 }
199 }
200
202e7223
C
201 return configuration
202}