aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/config/webpack.video-embed.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-07-23 14:49:52 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-07-23 15:10:57 +0200
commit202e72231750705b1a071d57206424eef1fc5be1 (patch)
treeaf19fc202d51764132d59cd0e99874c7de356f50 /client/config/webpack.video-embed.js
parent0c31c33dcb0baaa8d3aeedb63336dfe2ae6e5585 (diff)
downloadPeerTube-202e72231750705b1a071d57206424eef1fc5be1.tar.gz
PeerTube-202e72231750705b1a071d57206424eef1fc5be1.tar.zst
PeerTube-202e72231750705b1a071d57206424eef1fc5be1.zip
Process embed in webpack too
Diffstat (limited to 'client/config/webpack.video-embed.js')
-rw-r--r--client/config/webpack.video-embed.js183
1 files changed, 183 insertions, 0 deletions
diff --git a/client/config/webpack.video-embed.js b/client/config/webpack.video-embed.js
new file mode 100644
index 000000000..a04d5be8b
--- /dev/null
+++ b/client/config/webpack.video-embed.js
@@ -0,0 +1,183 @@
1const helpers = require('./helpers')
2
3const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin
4const HtmlWebpackPlugin = require('html-webpack-plugin')
5const UglifyJsPlugin = require('webpack/lib/optimize/UglifyJsPlugin')
6const HashedModuleIdsPlugin = require('webpack/lib/HashedModuleIdsPlugin')
7const ExtractTextPlugin = require('extract-text-webpack-plugin')
8const PurifyCSSPlugin = require('purifycss-webpack')
9
10module.exports = function (options) {
11 const isProd = options.env === 'production'
12
13 const configuration = {
14 entry: {
15 'video-embed': './src/standalone/videos/embed.ts'
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
26 modules: [ helpers.root('src'), helpers.root('node_modules') ]
27 },
28
29 output: {
30 path: helpers.root('dist/standalone/videos'),
31 filename: '[name].[hash].bundle.js',
32 sourceMapFilename: '[file].map',
33 chunkFilename: '[id].chunk.js',
34 publicPath: '/client/standalone/videos/'
35 },
36
37 module: {
38
39 rules: [
40 {
41 test: /\.ts$/,
42 use: [
43 {
44 loader: 'awesome-typescript-loader',
45 options: {
46 configFileName: 'tsconfig.webpack.json',
47 useCache: !isProd
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: {
70 sourceMap: true
71 }
72 },
73 {
74 loader: 'sass-resources-loader',
75 options: {
76 resources: [
77 helpers.root('src/sass/_variables.scss')
78 ]
79 }
80 }
81 ]
82 })
83 },
84
85 {
86 test: /\.html$/,
87 use: 'raw-loader',
88 exclude: [
89 helpers.root('src/index.html'),
90 helpers.root('src/standalone/videos/embed.html')
91 ]
92 },
93
94 {
95 test: /\.(jpg|png|gif)$/,
96 use: 'url-loader'
97 },
98
99 { test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, use: 'url-loader?limit=10000&minetype=application/font-woff' },
100 { test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, use: 'file-loader' }
101 ]
102
103 },
104
105 plugins: [
106 new ExtractTextPlugin({
107 filename: '[name].[contenthash].css'
108 }),
109
110 new PurifyCSSPlugin({
111 paths: [ helpers.root('src/standalone/videos/embed.ts') ],
112 purifyOptions: {
113 minify: true,
114 whitelist: [ '*vjs*', '*video-js*' ]
115 }
116 }),
117
118 new CheckerPlugin(),
119
120 new HtmlWebpackPlugin({
121 template: 'src/standalone/videos/embed.html',
122 filename: 'embed.html',
123 title: 'PeerTube',
124 chunksSortMode: 'dependency',
125 inject: 'body'
126 })
127 ],
128
129 node: {
130 global: true,
131 crypto: 'empty',
132 fs: 'empty',
133 process: true,
134 module: false,
135 clearImmediate: false,
136 setImmediate: false
137 }
138 }
139
140 if (isProd) {
141 configuration.module.rules.push(
142 {
143 test: /junk\/index\.js$/,
144 // exclude: /(node_modules|bower_components)/,
145 use: {
146 loader: 'babel-loader',
147 options: {
148 presets: [ 'env' ]
149 }
150 }
151 }
152 )
153
154 configuration.plugins.push(
155 new UglifyJsPlugin({
156 beautify: false,
157 output: {
158 comments: false
159 }, // prod
160 mangle: {
161 screw_ie8: true
162 }, // prod
163 compress: {
164 screw_ie8: true,
165 warnings: false,
166 conditionals: true,
167 unused: true,
168 comparisons: true,
169 sequences: true,
170 dead_code: true,
171 evaluate: true,
172 if_return: true,
173 join_vars: true,
174 negate_iife: false // we need this for lazy v8
175 }
176 }),
177
178 new HashedModuleIdsPlugin()
179 )
180 }
181
182 return configuration
183}