]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/webpack/webpack.video-embed.js
Relax migrations
[github/Chocobozzz/PeerTube.git] / client / webpack / webpack.video-embed.js
CommitLineData
202e7223 1const helpers = require('./helpers')
6cca7360 2const path = require('path')
202e7223
C
3
4const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin
5const HtmlWebpackPlugin = require('html-webpack-plugin')
ae04a0ce 6const TerserPlugin = require('terser-webpack-plugin')
7bfd1b1e 7const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin')
202e7223
C
8const ExtractTextPlugin = require('extract-text-webpack-plugin')
9const PurifyCSSPlugin = require('purifycss-webpack')
10
7bfd1b1e 11module.exports = function () {
202e7223
C
12 const configuration = {
13 entry: {
99941732
WL
14 'video-embed': './src/standalone/videos/embed.ts',
15 'player': './src/standalone/player/player.ts',
16 'test-embed': './src/standalone/videos/test-embed.ts'
202e7223
C
17 },
18
19 resolve: {
20 /*
21 * An array of extensions that should be used to resolve modules.
22 *
23 * See: http://webpack.github.io/docs/configuration.html#resolve-extensions
24 */
25 extensions: [ '.ts', '.js', '.json', '.scss' ],
26
6cca7360
C
27 modules: [ helpers.root('src'), helpers.root('node_modules') ],
28
29 alias: {
512decf3 30 'video.js$': path.resolve('node_modules/video.js/core.js')
6cca7360 31 }
202e7223
C
32 },
33
34 output: {
35 path: helpers.root('dist/standalone/videos'),
36 filename: '[name].[hash].bundle.js',
37 sourceMapFilename: '[file].map',
38 chunkFilename: '[id].chunk.js',
39 publicPath: '/client/standalone/videos/'
40 },
41
d1a63fc7 42 devtool: process.env.NODE_ENV === 'production' ? false : 'source-map',
f6a7c82c 43
202e7223
C
44 module: {
45
46 rules: [
47 {
48 test: /\.ts$/,
49 use: [
50 {
51 loader: 'awesome-typescript-loader',
52 options: {
7bfd1b1e 53 configFileName: 'tsconfig.json'
202e7223
C
54 }
55 }
56 ],
57 exclude: [/\.(spec|e2e)\.ts$/]
58 },
59
60 {
61 test: /\.(sass|scss)$/,
62 use: ExtractTextPlugin.extract({
63 fallback: 'style-loader',
64 use: [
65 {
66 loader: 'css-loader',
67 options: {
68 sourceMap: true,
69 importLoaders: 1
70 }
71 },
ae04a0ce
C
72 // {
73 // loader: 'resolve-url-loader',
74 // options: {
75 // debug: true
76 // }
77 // },
202e7223
C
78 {
79 loader: 'sass-loader',
80 options: {
4adebd51
C
81 sassOptions: {
82 sourceMap: true,
83 includePaths: [
84 helpers.root('src/sass/include')
85 ]
86 }
202e7223
C
87 }
88 }
89 ]
90 })
91 },
92
93 {
94 test: /\.html$/,
95 use: 'raw-loader',
96 exclude: [
97 helpers.root('src/index.html'),
99941732
WL
98 helpers.root('src/standalone/videos/embed.html'),
99 helpers.root('src/standalone/videos/test-embed.html')
202e7223
C
100 ]
101 },
102
103 {
104 test: /\.(jpg|png|gif)$/,
105 use: 'url-loader'
106 },
107
108 { test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, use: 'url-loader?limit=10000&minetype=application/font-woff' },
109 { test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, use: 'file-loader' }
110 ]
111
112 },
113
114 plugins: [
115 new ExtractTextPlugin({
fc9e6624 116 filename: '[name].[hash].css'
202e7223
C
117 }),
118
119 new PurifyCSSPlugin({
ae04a0ce 120 paths: [
99941732 121 helpers.root('src/standalone/videos/embed.ts'),
ae04a0ce 122 helpers.root('src/standalone/videos/test-embed.html')
99941732 123 ],
202e7223
C
124 purifyOptions: {
125 minify: true,
126 whitelist: [ '*vjs*', '*video-js*' ]
127 }
128 }),
129
130 new CheckerPlugin(),
131
132 new HtmlWebpackPlugin({
133 template: 'src/standalone/videos/embed.html',
134 filename: 'embed.html',
135 title: 'PeerTube',
4adebd51 136 chunksSortMode: 'auto',
99941732
WL
137 inject: 'body',
138 chunks: ['video-embed']
139 }),
140
141 new HtmlWebpackPlugin({
142 template: '!!html-loader!src/standalone/videos/test-embed.html',
143 filename: 'test-embed.html',
144 title: 'PeerTube',
4adebd51 145 chunksSortMode: 'auto',
99941732
WL
146 inject: 'body',
147 chunks: ['test-embed']
7bfd1b1e
C
148 }),
149
150 /**
151 * Plugin LoaderOptionsPlugin (experimental)
152 *
153 * See: https://gist.github.com/sokra/27b24881210b56bbaff7
154 */
155 new LoaderOptionsPlugin({
156 options: {
157 context: __dirname,
158 output: {
159 path: helpers.root('dist')
160 }
161 }
202e7223
C
162 })
163 ],
164
ae04a0ce
C
165 optimization: {
166 minimizer: [
167 new TerserPlugin({
168 terserOptions: {
169 ecma: 6,
170 warnings: false,
171 ie8: false,
172 mangle: true,
173 compress: {
174 passes: 3,
175 pure_getters: true
176 },
177 output: {
178 ascii_only: true,
179 comments: false
180 }
181 }
182 })
183 ]
184 },
185
fc9e6624 186 performance: {
efda99c3
C
187 maxEntrypointSize: 700000, // 600kB
188 maxAssetSize: 700000
fc9e6624
C
189 },
190
202e7223
C
191 node: {
192 global: true,
193 crypto: 'empty',
194 fs: 'empty',
195 process: true,
196 module: false,
197 clearImmediate: false,
198 setImmediate: false
199 }
200 }
201
202e7223
C
202 return configuration
203}