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