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