]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/config/webpack.dev.js
First draft to use webpack instead of systemjs
[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')
9
10/**
11 * Webpack Constants
12 */
13const ENV = process.env.ENV = process.env.NODE_ENV = 'development'
14const HMR = helpers.hasProcessFlag('hot')
15const METADATA = webpackMerge(commonConfig.metadata, {
16 host: 'localhost',
17 port: 3000,
18 ENV: ENV,
19 HMR: HMR
20})
21
22/**
23 * Webpack configuration
24 *
25 * See: http://webpack.github.io/docs/configuration.html#cli
26 */
27module.exports = webpackMerge(commonConfig, {
28 /**
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 /**
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].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].map',
78
79 /** The filename of non-entry chunks as relative path
80 * inside the output.path directory.
81 *
82 * See: http://webpack.github.io/docs/configuration.html#output-chunkfilename
83 */
84 chunkFilename: '[id].chunk.js',
85
86 publicPath: '/client/'
87
88 },
89
90 plugins: [
91
92 /**
93 * Plugin: DefinePlugin
94 * Description: Define free variables.
95 * Useful for having development builds with debug logging or adding global constants.
96 *
97 * Environment helpers
98 *
99 * See: https://webpack.github.io/docs/list-of-plugins.html#defineplugin
100 */
101 // NOTE: when adding more properties, make sure you include them in custom-typings.d.ts
102 new DefinePlugin({
103 'ENV': JSON.stringify(METADATA.ENV),
104 'HMR': METADATA.HMR,
105 'process.env': {
106 'ENV': JSON.stringify(METADATA.ENV),
107 'NODE_ENV': JSON.stringify(METADATA.ENV),
108 'HMR': METADATA.HMR
109 }
110 })
111 ],
112
113 /**
114 * Static analysis linter for TypeScript advanced options configuration
115 * Description: An extensible linter for the TypeScript language.
116 *
117 * See: https://github.com/wbuchwalter/tslint-loader
118 */
119 tslint: {
120 emitErrors: false,
121 failOnHint: false,
122 resourcePath: 'src'
123 },
124
125 /**
126 * Webpack Development Server configuration
127 * Description: The webpack-dev-server is a little node.js Express server.
128 * The server emits information about the compilation state to the client,
129 * which reacts to those events.
130 *
131 * See: https://webpack.github.io/docs/webpack-dev-server.html
132 */
133 devServer: {
134 port: METADATA.port,
135 host: METADATA.host,
136 historyApiFallback: true,
137 watchOptions: {
138 aggregateTimeout: 300,
139 poll: 1000
140 },
141 outputPath: helpers.root('dist')
142 },
143
144 /*
145 * Include polyfills or mocks for various node stuff
146 * Description: Node configuration
147 *
148 * See: https://webpack.github.io/docs/configuration.html#node
149 */
150 node: {
151 global: 'window',
152 crypto: 'empty',
153 process: true,
154 module: false,
155 clearImmediate: false,
156 setImmediate: false
157 }
158
159})