aboutsummaryrefslogtreecommitdiffhomepage
path: root/client
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-09-19 22:27:17 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-09-19 22:27:17 +0200
commitad22074a780b4bdbe3cd9e903b3fa5ef83eaef14 (patch)
treefc44ffb9e7feba0688eed18b41af8b6df693cf7d /client
parentd268c551cc0cbe2f83f8cc9533ce5f636eda860a (diff)
downloadPeerTube-ad22074a780b4bdbe3cd9e903b3fa5ef83eaef14.tar.gz
PeerTube-ad22074a780b4bdbe3cd9e903b3fa5ef83eaef14.tar.zst
PeerTube-ad22074a780b4bdbe3cd9e903b3fa5ef83eaef14.zip
Client: fix prod build process
Diffstat (limited to 'client')
-rw-r--r--client/config/webpack.common.js12
-rw-r--r--client/config/webpack.prod.js346
-rw-r--r--client/package.json7
-rw-r--r--client/tsconfig.json4
4 files changed, 182 insertions, 187 deletions
diff --git a/client/config/webpack.common.js b/client/config/webpack.common.js
index 88a3639d2..882013a9e 100644
--- a/client/config/webpack.common.js
+++ b/client/config/webpack.common.js
@@ -142,15 +142,11 @@ module.exports = function (options) {
142 }, 142 },
143 143
144 { 144 {
145 test: /\.scss$/, 145 test: /\.(sass|scss)$/,
146 exclude: /node_modules/, 146 loaders: ['css-to-string-loader', 'css-loader?sourceMap', 'resolve-url', 'sass-loader?sourceMap']
147 loaders: [ 'raw-loader', 'sass-loader' ]
148 },
149
150 {
151 test: /\.(woff2?|ttf|eot|svg)$/,
152 loader: 'url?limit=10000&name=assets/fonts/[hash].[ext]'
153 }, 147 },
148 { test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'url?limit=10000&minetype=application/font-woff' },
149 { test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'file' },
154 150
155 /* Raw loader support for *.html 151 /* Raw loader support for *.html
156 * Returns file content as string 152 * Returns file content as string
diff --git a/client/config/webpack.prod.js b/client/config/webpack.prod.js
index 2db41d398..46db54482 100644
--- a/client/config/webpack.prod.js
+++ b/client/config/webpack.prod.js
@@ -30,201 +30,203 @@ const METADATA = webpackMerge(commonConfig({env: ENV}).metadata, {
30 HMR: false 30 HMR: false
31}) 31})
32 32
33module.exports = webpackMerge(commonConfig, { 33module.exports = function (env) {
34 /** 34 return webpackMerge(commonConfig({env: ENV}), {
35 * Switch loaders to debug mode.
36 *
37 * See: http://webpack.github.io/docs/configuration.html#debug
38 */
39 debug: false,
40
41 /**
42 * Developer tool to enhance debugging
43 *
44 * See: http://webpack.github.io/docs/configuration.html#devtool
45 * See: https://github.com/webpack/docs/wiki/build-performance#sourcemaps
46 */
47 devtool: 'source-map',
48
49 /**
50 * Options affecting the output of the compilation.
51 *
52 * See: http://webpack.github.io/docs/configuration.html#output
53 */
54 output: {
55 /** 35 /**
56 * The output directory as absolute path (required). 36 * Switch loaders to debug mode.
57 * 37 *
58 * See: http://webpack.github.io/docs/configuration.html#output-path 38 * See: http://webpack.github.io/docs/configuration.html#debug
59 */ 39 */
60 path: helpers.root('dist'), 40 debug: false,
61 41
62 /** 42 /**
63 * Specifies the name of each output file on disk. 43 * Developer tool to enhance debugging
64 * IMPORTANT: You must not specify an absolute path here!
65 * 44 *
66 * See: http://webpack.github.io/docs/configuration.html#output-filename 45 * See: http://webpack.github.io/docs/configuration.html#devtool
46 * See: https://github.com/webpack/docs/wiki/build-performance#sourcemaps
67 */ 47 */
68 filename: '[name].[chunkhash].bundle.js', 48 devtool: 'source-map',
69 49
70 /** 50 /**
71 * The filename of the SourceMaps for the JavaScript files. 51 * Options affecting the output of the compilation.
72 * They are inside the output.path directory.
73 * 52 *
74 * See: http://webpack.github.io/docs/configuration.html#output-sourcemapfilename 53 * See: http://webpack.github.io/docs/configuration.html#output
75 */ 54 */
76 sourceMapFilename: '[name].[chunkhash].bundle.map', 55 output: {
56 /**
57 * The output directory as absolute path (required).
58 *
59 * See: http://webpack.github.io/docs/configuration.html#output-path
60 */
61 path: helpers.root('dist'),
62
63 /**
64 * Specifies the name of each output file on disk.
65 * IMPORTANT: You must not specify an absolute path here!
66 *
67 * See: http://webpack.github.io/docs/configuration.html#output-filename
68 */
69 filename: '[name].[chunkhash].bundle.js',
70
71 /**
72 * The filename of the SourceMaps for the JavaScript files.
73 * They are inside the output.path directory.
74 *
75 * See: http://webpack.github.io/docs/configuration.html#output-sourcemapfilename
76 */
77 sourceMapFilename: '[name].[chunkhash].bundle.map',
78
79 /**
80 * The filename of non-entry chunks as relative path
81 * inside the output.path directory.
82 *
83 * See: http://webpack.github.io/docs/configuration.html#output-chunkfilename
84 */
85 chunkFilename: '[id].[chunkhash].chunk.js'
86
87 },
88
89 externals: {
90 webtorrent: 'WebTorrent'
91 },
77 92
78 /** 93 /**
79 * The filename of non-entry chunks as relative path 94 * Add additional plugins to the compiler.
80 * inside the output.path directory.
81 * 95 *
82 * See: http://webpack.github.io/docs/configuration.html#output-chunkfilename 96 * See: http://webpack.github.io/docs/configuration.html#plugins
83 */ 97 */
84 chunkFilename: '[id].[chunkhash].chunk.js' 98 plugins: [
85 99
86 }, 100 /**
87 101 * Plugin: WebpackMd5Hash
88 externals: { 102 * Description: Plugin to replace a standard webpack chunkhash with md5.
89 webtorrent: 'WebTorrent' 103 *
90 }, 104 * See: https://www.npmjs.com/package/webpack-md5-hash
91 105 */
92 /** 106 new WebpackMd5Hash(),
93 * Add additional plugins to the compiler. 107
94 * 108 /**
95 * See: http://webpack.github.io/docs/configuration.html#plugins 109 * Plugin: DedupePlugin
96 */ 110 * Description: Prevents the inclusion of duplicate code into your bundle
97 plugins: [ 111 * and instead applies a copy of the function at runtime.
98 112 *
99 /** 113 * See: https://webpack.github.io/docs/list-of-plugins.html#defineplugin
100 * Plugin: WebpackMd5Hash 114 * See: https://github.com/webpack/docs/wiki/optimization#deduplication
101 * Description: Plugin to replace a standard webpack chunkhash with md5. 115 */
102 * 116 // new DedupePlugin(),
103 * See: https://www.npmjs.com/package/webpack-md5-hash 117
104 */ 118 /**
105 new WebpackMd5Hash(), 119 * Plugin: DefinePlugin
120 * Description: Define free variables.
121 * Useful for having development builds with debug logging or adding global constants.
122 *
123 * Environment helpers
124 *
125 * See: https://webpack.github.io/docs/list-of-plugins.html#defineplugin
126 */
127 // NOTE: when adding more properties make sure you include them in custom-typings.d.ts
128 new DefinePlugin({
129 'ENV': JSON.stringify(METADATA.ENV),
130 'HMR': METADATA.HMR,
131 'process.env': {
132 'ENV': JSON.stringify(METADATA.ENV),
133 'NODE_ENV': JSON.stringify(METADATA.ENV),
134 'HMR': METADATA.HMR
135 }
136 }),
137
138 /**
139 * Plugin: UglifyJsPlugin
140 * Description: Minimize all JavaScript output of chunks.
141 * Loaders are switched into minimizing mode.
142 *
143 * See: https://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin
144 */
145 // NOTE: To debug prod builds uncomment //debug lines and comment //prod lines
146 new UglifyJsPlugin({
147 // beautify: true, //debug
148 // mangle: false, //debug
149 // dead_code: false, //debug
150 // unused: false, //debug
151 // deadCode: false, //debug
152 // compress: {
153 // screw_ie8: true,
154 // keep_fnames: true,
155 // drop_debugger: false,
156 // dead_code: false,
157 // unused: false
158 // }, // debug
159 // comments: true, //debug
160
161 beautify: false, // prod
162 mangle: { screw_ie8: true, keep_fnames: true }, // prod
163 compress: { screw_ie8: true }, // prod
164 comments: false // prod
165 }),
166
167 new NormalModuleReplacementPlugin(
168 /angular2-hmr/,
169 helpers.root('config/modules/angular2-hmr-prod.js')
170 )
171
172 /**
173 * Plugin: CompressionPlugin
174 * Description: Prepares compressed versions of assets to serve
175 * them with Content-Encoding
176 *
177 * See: https://github.com/webpack/compression-webpack-plugin
178 */
179 // new CompressionPlugin({
180 // regExp: /\.css$|\.html$|\.js$|\.map$/,
181 // threshold: 2 * 1024
182 // })
106 183
107 /** 184 ],
108 * Plugin: DedupePlugin
109 * Description: Prevents the inclusion of duplicate code into your bundle
110 * and instead applies a copy of the function at runtime.
111 *
112 * See: https://webpack.github.io/docs/list-of-plugins.html#defineplugin
113 * See: https://github.com/webpack/docs/wiki/optimization#deduplication
114 */
115 // new DedupePlugin(),
116 185
117 /** 186 /**
118 * Plugin: DefinePlugin 187 * Static analysis linter for TypeScript advanced options configuration
119 * Description: Define free variables. 188 * Description: An extensible linter for the TypeScript language.
120 * Useful for having development builds with debug logging or adding global constants.
121 *
122 * Environment helpers
123 * 189 *
124 * See: https://webpack.github.io/docs/list-of-plugins.html#defineplugin 190 * See: https://github.com/wbuchwalter/tslint-loader
125 */ 191 */
126 // NOTE: when adding more properties make sure you include them in custom-typings.d.ts 192 tslint: {
127 new DefinePlugin({ 193 emitErrors: true,
128 'ENV': JSON.stringify(METADATA.ENV), 194 failOnHint: true,
129 'HMR': METADATA.HMR, 195 resourcePath: 'src'
130 'process.env': { 196 },
131 'ENV': JSON.stringify(METADATA.ENV),
132 'NODE_ENV': JSON.stringify(METADATA.ENV),
133 'HMR': METADATA.HMR
134 }
135 }),
136 197
137 /** 198 /**
138 * Plugin: UglifyJsPlugin 199 * Html loader advanced options
139 * Description: Minimize all JavaScript output of chunks.
140 * Loaders are switched into minimizing mode.
141 * 200 *
142 * See: https://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin 201 * See: https://github.com/webpack/html-loader#advanced-options
143 */ 202 */
144 // NOTE: To debug prod builds uncomment //debug lines and comment //prod lines 203 // TODO: Need to workaround Angular 2's html syntax => #id [bind] (event) *ngFor
145 new UglifyJsPlugin({ 204 htmlLoader: {
146 // beautify: true, //debug 205 minimize: true,
147 // mangle: false, //debug 206 removeAttributeQuotes: false,
148 // dead_code: false, //debug 207 caseSensitive: true,
149 // unused: false, //debug 208 customAttrSurround: [
150 // deadCode: false, //debug 209 [/#/, /(?:)/],
151 // compress: { 210 [/\*/, /(?:)/],
152 // screw_ie8: true, 211 [/\[?\(?/, /(?:)/]
153 // keep_fnames: true, 212 ],
154 // drop_debugger: false, 213 customAttrAssign: [/\)?\]?=/]
155 // dead_code: false, 214 },
156 // unused: false 215
157 // }, // debug 216 /*
158 // comments: true, //debug 217 * Include polyfills or mocks for various node stuff
159 218 * Description: Node configuration
160 beautify: false, // prod
161 mangle: { screw_ie8: true, keep_fnames: true }, // prod
162 compress: { screw_ie8: true }, // prod
163 comments: false // prod
164 }),
165
166 new NormalModuleReplacementPlugin(
167 /angular2-hmr/,
168 helpers.root('config/modules/angular2-hmr-prod.js')
169 )
170
171 /**
172 * Plugin: CompressionPlugin
173 * Description: Prepares compressed versions of assets to serve
174 * them with Content-Encoding
175 * 219 *
176 * See: https://github.com/webpack/compression-webpack-plugin 220 * See: https://webpack.github.io/docs/configuration.html#node
177 */ 221 */
178 // new CompressionPlugin({ 222 node: {
179 // regExp: /\.css$|\.html$|\.js$|\.map$/, 223 global: 'window',
180 // threshold: 2 * 1024 224 crypto: 'empty',
181 // }) 225 process: false,
182 226 module: false,
183 ], 227 clearImmediate: false,
184 228 setImmediate: false
185 /** 229 }
186 * Static analysis linter for TypeScript advanced options configuration 230
187 * Description: An extensible linter for the TypeScript language. 231 })
188 * 232}
189 * See: https://github.com/wbuchwalter/tslint-loader
190 */
191 tslint: {
192 emitErrors: true,
193 failOnHint: true,
194 resourcePath: 'src'
195 },
196
197 /**
198 * Html loader advanced options
199 *
200 * See: https://github.com/webpack/html-loader#advanced-options
201 */
202 // TODO: Need to workaround Angular 2's html syntax => #id [bind] (event) *ngFor
203 htmlLoader: {
204 minimize: true,
205 removeAttributeQuotes: false,
206 caseSensitive: true,
207 customAttrSurround: [
208 [/#/, /(?:)/],
209 [/\*/, /(?:)/],
210 [/\[?\(?/, /(?:)/]
211 ],
212 customAttrAssign: [/\)?\]?=/]
213 },
214
215 /*
216 * Include polyfills or mocks for various node stuff
217 * Description: Node configuration
218 *
219 * See: https://webpack.github.io/docs/configuration.html#node
220 */
221 node: {
222 global: 'window',
223 crypto: 'empty',
224 process: false,
225 module: false,
226 clearImmediate: false,
227 setImmediate: false
228 }
229
230})
diff --git a/client/package.json b/client/package.json
index 8899429db..94b028ffd 100644
--- a/client/package.json
+++ b/client/package.json
@@ -43,6 +43,7 @@
43 "copy-webpack-plugin": "^3.0.1", 43 "copy-webpack-plugin": "^3.0.1",
44 "core-js": "^2.4.1", 44 "core-js": "^2.4.1",
45 "css-loader": "^0.25.0", 45 "css-loader": "^0.25.0",
46 "css-to-string-loader": "^0.1.1",
46 "es6-promise": "^3.0.2", 47 "es6-promise": "^3.0.2",
47 "es6-promise-loader": "^1.0.1", 48 "es6-promise-loader": "^1.0.1",
48 "es6-shim": "^0.35.0", 49 "es6-shim": "^0.35.0",
@@ -53,13 +54,13 @@
53 "json-loader": "^0.5.4", 54 "json-loader": "^0.5.4",
54 "ng2-bootstrap": "^1.1.5", 55 "ng2-bootstrap": "^1.1.5",
55 "ng2-file-upload": "^1.0.3", 56 "ng2-file-upload": "^1.0.3",
56 "node-sass": "^3.7.0", 57 "node-sass": "^3.10.0",
57 "normalize.css": "^4.1.1", 58 "normalize.css": "^4.1.1",
58 "raw-loader": "^0.5.1", 59 "raw-loader": "^0.5.1",
59 "reflect-metadata": "0.1.3", 60 "reflect-metadata": "0.1.3",
60 "resolve-url-loader": "^1.4.3", 61 "resolve-url-loader": "^1.6.0",
61 "rxjs": "5.0.0-beta.12", 62 "rxjs": "5.0.0-beta.12",
62 "sass-loader": "^3.2.0", 63 "sass-loader": "^3.2.3",
63 "source-map-loader": "^0.1.5", 64 "source-map-loader": "^0.1.5",
64 "string-replace-loader": "^1.0.3", 65 "string-replace-loader": "^1.0.3",
65 "style-loader": "^0.13.1", 66 "style-loader": "^0.13.1",
diff --git a/client/tsconfig.json b/client/tsconfig.json
index c4e2a8804..10573b8ee 100644
--- a/client/tsconfig.json
+++ b/client/tsconfig.json
@@ -17,11 +17,7 @@
17 "es6" 17 "es6"
18 ], 18 ],
19 "types": [ 19 "types": [
20 "hammerjs",
21 "jasmine",
22 "node", 20 "node",
23 "protractor",
24 "selenium-webdriver",
25 "source-map", 21 "source-map",
26 "uglify-js", 22 "uglify-js",
27 "webpack" 23 "webpack"