]>
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
5 const videoEmbedConfig
= require('./webpack.video-embed.js')
10 const AddAssetHtmlPlugin
= require('add-asset-html-webpack-plugin')
11 const DefinePlugin
= require('webpack/lib/DefinePlugin')
12 const NamedModulesPlugin
= require('webpack/lib/NamedModulesPlugin')
13 const LoaderOptionsPlugin
= require('webpack/lib/LoaderOptionsPlugin')
18 const ENV
= process
.env
.ENV
= process
.env
.NODE_ENV
= 'development'
19 const HOST
= process
.env
.HOST
|| 'localhost'
20 const PORT
= process
.env
.PORT
|| 3000
21 const HMR
= helpers
.hasProcessFlag('hot')
22 const METADATA
= webpackMerge(commonConfig({env: ENV
}).metadata
, {
27 API_URL: 'http://localhost:9000'
30 const DllBundlesPlugin
= require('webpack-dll-bundles-plugin').DllBundlesPlugin
33 * Webpack configuration
35 * See: http://webpack.github.io/docs/configuration.html#cli
37 module
.exports = function (env
) {
40 webpackMerge(commonConfig({ env: ENV
}), {
42 * Developer tool to enhance debugging
44 * See: http://webpack.github.io/docs/configuration.html#devtool
45 * See: https://github.com/webpack/docs/wiki/build-performance#sourcemaps
47 devtool: 'cheap-module-source-map',
50 * Options affecting the output of the compilation.
52 * See: http://webpack.github.io/docs/configuration.html#output
56 * The output directory as absolute path (required).
58 * See: http://webpack.github.io/docs/configuration.html#output-path
60 path: helpers
.root('dist'),
63 * Specifies the name of each output file on disk.
64 * IMPORTANT: You must not specify an absolute path here!
66 * See: http://webpack.github.io/docs/configuration.html#output-filename
68 filename: '[name].bundle.js',
71 * The filename of the SourceMaps for the JavaScript files.
72 * They are inside the output.path directory.
74 * See: http://webpack.github.io/docs/configuration.html#output-sourcemapfilename
76 sourceMapFilename: '[name].map',
78 /** The filename of non-entry chunks as relative path
79 * inside the output.path directory.
81 * See: http://webpack.github.io/docs/configuration.html#output-chunkfilename
83 chunkFilename: '[id].chunk.js',
91 // Too slow, life is short
97 // loader: 'tslint-loader',
99 // configFile: 'tslint.json'
104 // /\.(spec|e2e)\.ts$/,
114 * Plugin: DefinePlugin
115 * Description: Define free variables.
116 * Useful for having development builds with debug logging or adding global constants.
118 * Environment helpers
120 * See: https://webpack.github.io/docs/list-of-plugins.html#defineplugin
122 // NOTE: when adding more properties, make sure you include them in custom-typings.d.ts
124 'ENV': JSON
.stringify(METADATA
.ENV
),
126 'API_URL': JSON
.stringify(METADATA
.API_URL
),
127 'process.version': JSON
.stringify(process
.version
),
129 'ENV': JSON
.stringify(METADATA
.ENV
),
130 'NODE_ENV': JSON
.stringify(METADATA
.ENV
),
135 new DllBundlesPlugin({
141 path: 'zone.js/dist/zone.js'
145 path: 'zone.js/dist/long-stack-trace-zone.js'
149 '@angular/platform-browser',
150 '@angular/platform-browser-dynamic',
160 dllDir: helpers
.root('dll'),
161 webpackConfig: webpackMergeDll(commonConfig({env: ENV
}), {
162 devtool: 'cheap-module-source-map',
168 * Plugin: AddAssetHtmlPlugin
169 * Description: Adds the given JS or CSS file to the files
170 * Webpack knows about, and put it into the list of assets
171 * html-webpack-plugin injects into the generated html.
173 * See: https://github.com/SimenB/add-asset-html-webpack-plugin
175 new AddAssetHtmlPlugin([
176 { filepath: helpers
.root(`dll/${DllBundlesPlugin.resolveFile('polyfills')}`) },
177 { filepath: helpers
.root(`dll/${DllBundlesPlugin.resolveFile('vendor')}`) }
181 * Plugin: NamedModulesPlugin (experimental)
182 * Description: Uses file names as module name.
184 * See: https://github.com/webpack/webpack/commit/a04ffb928365b19feb75087c63f13cadfc08e1eb
186 new NamedModulesPlugin(),
189 * Plugin LoaderOptionsPlugin (experimental)
191 * See: https://gist.github.com/sokra/27b24881210b56bbaff7
193 new LoaderOptionsPlugin({
198 * Static analysis linter for TypeScript advanced options configuration
199 * Description: An extensible linter for the TypeScript language.
201 * See: https://github.com/wbuchwalter/tslint-loader
211 // https://github.com/bholloway/resolve-url-loader/issues/36
212 // https://github.com/jtangelder/sass-loader/issues/289
215 path: helpers
.root('dist')
224 * Webpack Development Server configuration
225 * Description: The webpack-dev-server is a little node.js Express server.
226 * The server emits information about the compilation state to the client,
227 * which reacts to those events.
229 * See: https://webpack.github.io/docs/webpack-dev-server.html
234 historyApiFallback: true,
236 ignored: /node_modules/
241 * Include polyfills or mocks for various node stuff
242 * Description: Node configuration
244 * See: https://webpack.github.io/docs/configuration.html#node
252 clearImmediate: false,
257 videoEmbedConfig({env: ENV
})