]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/config/webpack.dev.js
Client: fix handle refresh token
[github/Chocobozzz/PeerTube.git] / client / config / webpack.dev.js
CommitLineData
4a6995be
C
1const helpers = require('./helpers')
2const webpackMerge = require('webpack-merge') // used to merge webpack configs
3const commonConfig = require('./webpack.common.js') // the settings that are common to prod and dev
4
5/**
6 * Webpack Plugins
7 */
8const DefinePlugin = require('webpack/lib/DefinePlugin')
ab32b0fc 9const NamedModulesPlugin = require('webpack/lib/NamedModulesPlugin')
4a6995be
C
10
11/**
12 * Webpack Constants
13 */
14const ENV = process.env.ENV = process.env.NODE_ENV = 'development'
ab32b0fc
C
15const HOST = process.env.HOST || 'localhost'
16const PORT = process.env.PORT || 3000
4a6995be 17const HMR = helpers.hasProcessFlag('hot')
2e92c10b 18const METADATA = webpackMerge(commonConfig({env: ENV}).metadata, {
ab32b0fc
C
19 host: HOST,
20 port: PORT,
4a6995be
C
21 ENV: ENV,
22 HMR: HMR
23})
24
25/**
26 * Webpack configuration
27 *
28 * See: http://webpack.github.io/docs/configuration.html#cli
29 */
f9b2d2ce
C
30module.exports = function (env) {
31 return webpackMerge(commonConfig({env: ENV}), {
4a6995be 32 /**
f9b2d2ce 33 * Merged metadata from webpack.common.js for index.html
4a6995be 34 *
f9b2d2ce 35 * See: (custom attribute)
4a6995be 36 */
f9b2d2ce 37 metadata: METADATA,
4a6995be
C
38
39 /**
f9b2d2ce 40 * Switch loaders to debug mode.
4a6995be 41 *
f9b2d2ce 42 * See: http://webpack.github.io/docs/configuration.html#debug
4a6995be 43 */
f9b2d2ce 44 debug: true,
4a6995be
C
45
46 /**
f9b2d2ce 47 * Developer tool to enhance debugging
4a6995be 48 *
f9b2d2ce
C
49 * See: http://webpack.github.io/docs/configuration.html#devtool
50 * See: https://github.com/webpack/docs/wiki/build-performance#sourcemaps
4a6995be 51 */
f9b2d2ce 52 devtool: 'cheap-module-source-map',
4a6995be 53
f9b2d2ce
C
54 /**
55 * Options affecting the output of the compilation.
4a6995be 56 *
f9b2d2ce 57 * See: http://webpack.github.io/docs/configuration.html#output
4a6995be 58 */
f9b2d2ce
C
59 output: {
60 /**
61 * The output directory as absolute path (required).
62 *
63 * See: http://webpack.github.io/docs/configuration.html#output-path
64 */
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'
ab32b0fc 92
f9b2d2ce 93 },
4a6995be 94
f9b2d2ce
C
95 externals: {
96 webtorrent: 'WebTorrent'
97 },
4a6995be 98
f9b2d2ce
C
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 }),
7f82b8ae 120
f9b2d2ce
C
121 new NamedModulesPlugin()
122 ],
4a6995be
C
123
124 /**
f9b2d2ce
C
125 * Static analysis linter for TypeScript advanced options configuration
126 * Description: An extensible linter for the TypeScript language.
4a6995be 127 *
f9b2d2ce 128 * See: https://github.com/wbuchwalter/tslint-loader
4a6995be 129 */
f9b2d2ce
C
130 tslint: {
131 emitErrors: false,
132 failOnHint: false,
133 resourcePath: 'src'
ab32b0fc 134 },
4a6995be 135
f9b2d2ce
C
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
150 *
151 * See: https://webpack.github.io/docs/configuration.html#node
152 */
153 node: {
154 global: 'window',
155 crypto: 'empty',
156 process: true,
157 module: false,
158 clearImmediate: false,
159 setImmediate: false
160 }
161 })
162}