]>
git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/config/webpack.dev.js
1 const helpers
= require('./helpers')
2 const webpackMerge
= require('webpack-merge') // used to merge webpack configs
3 const webpackMergeDll
= webpackMerge
.strategy({plugins: 'replace'})
4 const commonConfig
= require('./webpack.common.js') // the settings that are common to prod and dev
9 const AddAssetHtmlPlugin
= require('add-asset-html-webpack-plugin')
10 const DefinePlugin
= require('webpack/lib/DefinePlugin')
11 const NamedModulesPlugin
= require('webpack/lib/NamedModulesPlugin')
12 const LoaderOptionsPlugin
= require('webpack/lib/LoaderOptionsPlugin')
17 const ENV
= process
.env
.ENV
= process
.env
.NODE_ENV
= 'development'
18 const HOST
= process
.env
.HOST
|| 'localhost'
19 const PORT
= process
.env
.PORT
|| 3000
20 const HMR
= helpers
.hasProcessFlag('hot')
21 const METADATA
= webpackMerge(commonConfig({env: ENV
}).metadata
, {
28 const DllBundlesPlugin
= require('webpack-dll-bundles-plugin').DllBundlesPlugin
31 * Webpack configuration
33 * See: http://webpack.github.io/docs/configuration.html#cli
35 module
.exports = function (env
) {
36 return webpackMerge(commonConfig({ env: ENV
}), {
38 * Developer tool to enhance debugging
40 * See: http://webpack.github.io/docs/configuration.html#devtool
41 * See: https://github.com/webpack/docs/wiki/build-performance#sourcemaps
43 devtool: 'cheap-module-source-map',
46 * Options affecting the output of the compilation.
48 * See: http://webpack.github.io/docs/configuration.html#output
52 * The output directory as absolute path (required).
54 * See: http://webpack.github.io/docs/configuration.html#output-path
56 path: helpers
.root('dist'),
59 * Specifies the name of each output file on disk.
60 * IMPORTANT: You must not specify an absolute path here!
62 * See: http://webpack.github.io/docs/configuration.html#output-filename
64 filename: '[name].bundle.js',
67 * The filename of the SourceMaps for the JavaScript files.
68 * They are inside the output.path directory.
70 * See: http://webpack.github.io/docs/configuration.html#output-sourcemapfilename
72 sourceMapFilename: '[name].map',
74 /** The filename of non-entry chunks as relative path
75 * inside the output.path directory.
77 * See: http://webpack.github.io/docs/configuration.html#output-chunkfilename
79 chunkFilename: '[id].chunk.js',
84 publicPath: '/client/'
88 webtorrent: 'WebTorrent'
94 * Plugin: DefinePlugin
95 * Description: Define free variables.
96 * Useful for having development builds with debug logging or adding global constants.
100 * See: https://webpack.github.io/docs/list-of-plugins.html#defineplugin
102 // NOTE: when adding more properties, make sure you include them in custom-typings.d.ts
104 'ENV': JSON
.stringify(METADATA
.ENV
),
107 'ENV': JSON
.stringify(METADATA
.ENV
),
108 'NODE_ENV': JSON
.stringify(METADATA
.ENV
),
113 new DllBundlesPlugin({
119 path: 'zone.js/dist/zone.js'
123 path: 'zone.js/dist/long-stack-trace-zone.js'
128 '@angular/platform-browser',
129 '@angular/platform-browser-dynamic',
139 dllDir: helpers
.root('dll'),
140 webpackConfig: webpackMergeDll(commonConfig({env: ENV
}), {
141 devtool: 'cheap-module-source-map',
147 * Plugin: AddAssetHtmlPlugin
148 * Description: Adds the given JS or CSS file to the files
149 * Webpack knows about, and put it into the list of assets
150 * html-webpack-plugin injects into the generated html.
152 * See: https://github.com/SimenB/add-asset-html-webpack-plugin
154 new AddAssetHtmlPlugin([
155 { filepath: helpers
.root(`dll/${DllBundlesPlugin.resolveFile('polyfills')}`) },
156 { filepath: helpers
.root(`dll/${DllBundlesPlugin.resolveFile('vendor')}`) }
160 * Plugin: NamedModulesPlugin (experimental)
161 * Description: Uses file names as module name.
163 * See: https://github.com/webpack/webpack/commit/a04ffb928365b19feb75087c63f13cadfc08e1eb
165 new NamedModulesPlugin(),
168 * Plugin LoaderOptionsPlugin (experimental)
170 * See: https://gist.github.com/sokra/27b24881210b56bbaff7
172 new LoaderOptionsPlugin({
177 * Static analysis linter for TypeScript advanced options configuration
178 * Description: An extensible linter for the TypeScript language.
180 * See: https://github.com/wbuchwalter/tslint-loader
189 // https://github.com/bholloway/resolve-url-loader/issues/36
190 // https://github.com/jtangelder/sass-loader/issues/289
193 path: helpers
.root('dist')
202 * Webpack Development Server configuration
203 * Description: The webpack-dev-server is a little node.js Express server.
204 * The server emits information about the compilation state to the client,
205 * which reacts to those events.
207 * See: https://webpack.github.io/docs/webpack-dev-server.html
212 historyApiFallback: true,
214 aggregateTimeout: 300,
217 outputPath: helpers
.root('dist')
221 * Include polyfills or mocks for various node stuff
222 * Description: Node configuration
224 * See: https://webpack.github.io/docs/configuration.html#node
231 clearImmediate: false,