aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/config/webpack.dev.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-10-02 15:39:09 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-10-02 15:39:09 +0200
commita6375e69668ea42e19531c6bc68dcd37f3f7cbd7 (patch)
tree03204a408d56311692c3528bedcf95d2455e94f2 /client/config/webpack.dev.js
parent052937db8a8d282eccdbdf38d487ed8d85d3c0a7 (diff)
parentc4403b29ad4db097af528a7f04eea07e0ed320d0 (diff)
downloadPeerTube-a6375e69668ea42e19531c6bc68dcd37f3f7cbd7.tar.gz
PeerTube-a6375e69668ea42e19531c6bc68dcd37f3f7cbd7.tar.zst
PeerTube-a6375e69668ea42e19531c6bc68dcd37f3f7cbd7.zip
Merge branch 'master' into webseed-merged
Diffstat (limited to 'client/config/webpack.dev.js')
-rw-r--r--client/config/webpack.dev.js218
1 files changed, 119 insertions, 99 deletions
diff --git a/client/config/webpack.dev.js b/client/config/webpack.dev.js
index 50193bf58..0b6c00cbd 100644
--- a/client/config/webpack.dev.js
+++ b/client/config/webpack.dev.js
@@ -6,15 +6,18 @@ const commonConfig = require('./webpack.common.js') // the settings that are com
6 * Webpack Plugins 6 * Webpack Plugins
7 */ 7 */
8const DefinePlugin = require('webpack/lib/DefinePlugin') 8const DefinePlugin = require('webpack/lib/DefinePlugin')
9const NamedModulesPlugin = require('webpack/lib/NamedModulesPlugin')
9 10
10/** 11/**
11 * Webpack Constants 12 * Webpack Constants
12 */ 13 */
13const ENV = process.env.ENV = process.env.NODE_ENV = 'development' 14const ENV = process.env.ENV = process.env.NODE_ENV = 'development'
15const HOST = process.env.HOST || 'localhost'
16const PORT = process.env.PORT || 3000
14const HMR = helpers.hasProcessFlag('hot') 17const HMR = helpers.hasProcessFlag('hot')
15const METADATA = webpackMerge(commonConfig.metadata, { 18const METADATA = webpackMerge(commonConfig({env: ENV}).metadata, {
16 host: 'localhost', 19 host: HOST,
17 port: 3000, 20 port: PORT,
18 ENV: ENV, 21 ENV: ENV,
19 HMR: HMR 22 HMR: HMR
20}) 23})
@@ -24,119 +27,136 @@ const METADATA = webpackMerge(commonConfig.metadata, {
24 * 27 *
25 * See: http://webpack.github.io/docs/configuration.html#cli 28 * See: http://webpack.github.io/docs/configuration.html#cli
26 */ 29 */
27module.exports = webpackMerge(commonConfig, { 30module.exports = function (env) {
28 /** 31 return webpackMerge(commonConfig({env: ENV}), {
29 * Merged metadata from webpack.common.js for index.html
30 *
31 * See: (custom attribute)
32 */
33 metadata: METADATA,
34
35 /**
36 * Switch loaders to debug mode.
37 *
38 * See: http://webpack.github.io/docs/configuration.html#debug
39 */
40 debug: true,
41
42 /**
43 * Developer tool to enhance debugging
44 *
45 * See: http://webpack.github.io/docs/configuration.html#devtool
46 * See: https://github.com/webpack/docs/wiki/build-performance#sourcemaps
47 */
48 devtool: 'cheap-module-source-map',
49
50 /**
51 * Options affecting the output of the compilation.
52 *
53 * See: http://webpack.github.io/docs/configuration.html#output
54 */
55 output: {
56 /** 32 /**
57 * The output directory as absolute path (required). 33 * Merged metadata from webpack.common.js for index.html
58 * 34 *
59 * See: http://webpack.github.io/docs/configuration.html#output-path 35 * See: (custom attribute)
60 */ 36 */
61 path: helpers.root('dist'), 37 metadata: METADATA,
62 38
63 /** 39 /**
64 * Specifies the name of each output file on disk. 40 * Switch loaders to debug mode.
65 * IMPORTANT: You must not specify an absolute path here!
66 * 41 *
67 * See: http://webpack.github.io/docs/configuration.html#output-filename 42 * See: http://webpack.github.io/docs/configuration.html#debug
68 */ 43 */
69 filename: '[name].bundle.js', 44 debug: true,
70 45
71 /** 46 /**
72 * The filename of the SourceMaps for the JavaScript files. 47 * Developer tool to enhance debugging
73 * They are inside the output.path directory.
74 * 48 *
75 * See: http://webpack.github.io/docs/configuration.html#output-sourcemapfilename 49 * See: http://webpack.github.io/docs/configuration.html#devtool
50 * See: https://github.com/webpack/docs/wiki/build-performance#sourcemaps
76 */ 51 */
77 sourceMapFilename: '[name].map', 52 devtool: 'cheap-module-source-map',
78 53
79 /** The filename of non-entry chunks as relative path 54 /**
80 * inside the output.path directory. 55 * Options affecting the output of the compilation.
81 * 56 *
82 * See: http://webpack.github.io/docs/configuration.html#output-chunkfilename 57 * See: http://webpack.github.io/docs/configuration.html#output
83 */ 58 */
84 chunkFilename: '[id].chunk.js' 59 output: {
85 60 /**
86 }, 61 * The output directory as absolute path (required).
87 62 *
88 externals: { 63 * See: http://webpack.github.io/docs/configuration.html#output-path
89 webtorrent: 'WebTorrent' 64 */
90 }, 65 path: helpers.root('dist'),
66
67 /**
68 * Specifies the name of each output file on disk.
69 * IMPORTANT: You must not specify an absolute path here!
70 *
71 * See: http://webpack.github.io/docs/configuration.html#output-filename
72 */
73 filename: '[name].bundle.js',
74
75 /**
76 * The filename of the SourceMaps for the JavaScript files.
77 * They are inside the output.path directory.
78 *
79 * See: http://webpack.github.io/docs/configuration.html#output-sourcemapfilename
80 */
81 sourceMapFilename: '[name].map',
82
83 /** The filename of non-entry chunks as relative path
84 * inside the output.path directory.
85 *
86 * See: http://webpack.github.io/docs/configuration.html#output-chunkfilename
87 */
88 chunkFilename: '[id].chunk.js',
89
90 library: 'ac_[name]',
91 libraryTarget: 'var'
92
93 },
94
95 externals: {
96 webtorrent: 'WebTorrent'
97 },
98
99 plugins: [
100
101 /**
102 * Plugin: DefinePlugin
103 * Description: Define free variables.
104 * Useful for having development builds with debug logging or adding global constants.
105 *
106 * Environment helpers
107 *
108 * See: https://webpack.github.io/docs/list-of-plugins.html#defineplugin
109 */
110 // NOTE: when adding more properties, make sure you include them in custom-typings.d.ts
111 new DefinePlugin({
112 'ENV': JSON.stringify(METADATA.ENV),
113 'HMR': METADATA.HMR,
114 'process.env': {
115 'ENV': JSON.stringify(METADATA.ENV),
116 'NODE_ENV': JSON.stringify(METADATA.ENV),
117 'HMR': METADATA.HMR
118 }
119 }),
91 120
92 plugins: [ 121 new NamedModulesPlugin()
122 ],
93 123
94 /** 124 /**
95 * Plugin: DefinePlugin 125 * Static analysis linter for TypeScript advanced options configuration
96 * Description: Define free variables. 126 * Description: An extensible linter for the TypeScript language.
97 * Useful for having development builds with debug logging or adding global constants.
98 * 127 *
99 * Environment helpers 128 * See: https://github.com/wbuchwalter/tslint-loader
129 */
130 tslint: {
131 emitErrors: false,
132 failOnHint: false,
133 resourcePath: 'src'
134 },
135
136 devServer: {
137 port: METADATA.port,
138 host: METADATA.host,
139 historyApiFallback: true,
140 watchOptions: {
141 aggregateTimeout: 300,
142 poll: 1000
143 },
144 outputPath: helpers.root('dist')
145 },
146
147 /*
148 * Include polyfills or mocks for various node stuff
149 * Description: Node configuration
100 * 150 *
101 * See: https://webpack.github.io/docs/list-of-plugins.html#defineplugin 151 * See: https://webpack.github.io/docs/configuration.html#node
102 */ 152 */
103 // NOTE: when adding more properties, make sure you include them in custom-typings.d.ts 153 node: {
104 new DefinePlugin({ 154 global: 'window',
105 'ENV': JSON.stringify(METADATA.ENV), 155 crypto: 'empty',
106 'HMR': METADATA.HMR, 156 process: true,
107 'process.env': { 157 module: false,
108 'ENV': JSON.stringify(METADATA.ENV), 158 clearImmediate: false,
109 'NODE_ENV': JSON.stringify(METADATA.ENV), 159 setImmediate: false
110 'HMR': METADATA.HMR 160 }
111 } 161 })
112 }) 162}
113 ],
114
115 /**
116 * Static analysis linter for TypeScript advanced options configuration
117 * Description: An extensible linter for the TypeScript language.
118 *
119 * See: https://github.com/wbuchwalter/tslint-loader
120 */
121 tslint: {
122 emitErrors: false,
123 failOnHint: false,
124 resourcePath: 'src'
125 },
126
127 /*
128 * Include polyfills or mocks for various node stuff
129 * Description: Node configuration
130 *
131 * See: https://webpack.github.io/docs/configuration.html#node
132 */
133 node: {
134 global: 'window',
135 crypto: 'empty',
136 process: true,
137 module: false,
138 clearImmediate: false,
139 setImmediate: false
140 }
141
142})