]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/webpack/webpack.video-embed.js
Add ability to set custom markdown in description
[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')
662351e6 7const ProvidePlugin = require('webpack/lib/ProvidePlugin')
4f926722 8const MiniCssExtractPlugin = require('mini-css-extract-plugin')
202e7223 9
7bfd1b1e 10module.exports = function () {
202e7223
C
11 const configuration = {
12 entry: {
99941732
WL
13 'video-embed': './src/standalone/videos/embed.ts',
14 'player': './src/standalone/player/player.ts',
15 'test-embed': './src/standalone/videos/test-embed.ts'
202e7223
C
16 },
17
18 resolve: {
19 /*
20 * An array of extensions that should be used to resolve modules.
21 *
22 * See: http://webpack.github.io/docs/configuration.html#resolve-extensions
23 */
24 extensions: [ '.ts', '.js', '.json', '.scss' ],
25
72aa835e 26 modules: [ helpers.root('src'), 'node_modules' ],
6cca7360
C
27
28 alias: {
71ab65d0 29 'video.js$': path.resolve('node_modules/video.js/core.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') ],
40 stream: [ path.resolve('src/shims/noop.ts') ],
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: {
583eb04b 72 configFile: 'tsconfig.base.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$/,
107 use: 'raw-loader',
108 exclude: [
109 helpers.root('src/index.html'),
99941732
WL
110 helpers.root('src/standalone/videos/embed.html'),
111 helpers.root('src/standalone/videos/test-embed.html')
202e7223
C
112 ]
113 },
114
115 {
116 test: /\.(jpg|png|gif)$/,
117 use: 'url-loader'
118 },
119
120 { test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, use: 'url-loader?limit=10000&minetype=application/font-woff' },
121 { test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, use: 'file-loader' }
122 ]
123
124 },
125
126 plugins: [
662351e6
C
127 new ProvidePlugin({
128 process: 'process/browser',
129 Buffer: [ 'buffer', 'Buffer' ]
130 }),
131
4f926722 132 new MiniCssExtractPlugin({
a3b5e78a
C
133 filename: process.env.ANALYZE_BUNDLE === 'true'
134 ? '[name].css'
662351e6 135 : '[name].[contenthash].css'
202e7223
C
136 }),
137
202e7223
C
138 new HtmlWebpackPlugin({
139 template: 'src/standalone/videos/embed.html',
140 filename: 'embed.html',
141 title: 'PeerTube',
4adebd51 142 chunksSortMode: 'auto',
99941732 143 inject: 'body',
662351e6 144 chunks: [ 'video-embed' ],
2564d97e 145 minify: {
146 collapseWhitespace: true,
147 removeComments: false,
148 removeRedundantAttributes: true,
149 removeScriptTypeAttributes: true,
150 removeStyleLinkTypeAttributes: true,
151 useShortDoctype: true
152 }
99941732
WL
153 }),
154
155 new HtmlWebpackPlugin({
156 template: '!!html-loader!src/standalone/videos/test-embed.html',
157 filename: 'test-embed.html',
158 title: 'PeerTube',
4adebd51 159 chunksSortMode: 'auto',
99941732 160 inject: 'body',
662351e6 161 chunks: [ 'test-embed' ]
7bfd1b1e
C
162 }),
163
164 /**
165 * Plugin LoaderOptionsPlugin (experimental)
166 *
167 * See: https://gist.github.com/sokra/27b24881210b56bbaff7
168 */
169 new LoaderOptionsPlugin({
170 options: {
171 context: __dirname,
172 output: {
173 path: helpers.root('dist')
174 }
175 }
202e7223
C
176 })
177 ],
178
ae04a0ce
C
179 optimization: {
180 minimizer: [
181 new TerserPlugin({
182 terserOptions: {
183 ecma: 6,
184 warnings: false,
185 ie8: false,
186 mangle: true,
187 compress: {
188 passes: 3,
189 pure_getters: true
190 },
191 output: {
192 ascii_only: true,
193 comments: false
194 }
195 }
196 })
197 ]
198 },
199
fc9e6624 200 performance: {
efda99c3
C
201 maxEntrypointSize: 700000, // 600kB
202 maxAssetSize: 700000
fc9e6624
C
203 },
204
202e7223 205 node: {
662351e6 206 global: true
202e7223
C
207 }
208 }
209
202e7223
C
210 return configuration
211}