aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/config/webpack.dev.js
diff options
context:
space:
mode:
Diffstat (limited to 'client/config/webpack.dev.js')
-rw-r--r--client/config/webpack.dev.js392
1 files changed, 199 insertions, 193 deletions
diff --git a/client/config/webpack.dev.js b/client/config/webpack.dev.js
index c472ac762..9cf09db0f 100644
--- a/client/config/webpack.dev.js
+++ b/client/config/webpack.dev.js
@@ -2,6 +2,7 @@ const helpers = require('./helpers')
2const webpackMerge = require('webpack-merge') // used to merge webpack configs 2const webpackMerge = require('webpack-merge') // used to merge webpack configs
3const webpackMergeDll = webpackMerge.strategy({plugins: 'replace'}) 3const webpackMergeDll = webpackMerge.strategy({plugins: 'replace'})
4const commonConfig = require('./webpack.common.js') // the settings that are common to prod and dev 4const commonConfig = require('./webpack.common.js') // the settings that are common to prod and dev
5const videoEmbedConfig = require('./webpack.video-embed.js')
5 6
6/** 7/**
7 * Webpack Plugins 8 * Webpack Plugins
@@ -34,220 +35,225 @@ const DllBundlesPlugin = require('webpack-dll-bundles-plugin').DllBundlesPlugin
34 * See: http://webpack.github.io/docs/configuration.html#cli 35 * See: http://webpack.github.io/docs/configuration.html#cli
35 */ 36 */
36module.exports = function (env) { 37module.exports = function (env) {
37 return webpackMerge(commonConfig({ env: ENV }), { 38 return [
38 /**
39 * Developer tool to enhance debugging
40 *
41 * See: http://webpack.github.io/docs/configuration.html#devtool
42 * See: https://github.com/webpack/docs/wiki/build-performance#sourcemaps
43 */
44 devtool: 'cheap-module-source-map',
45
46 /**
47 * Options affecting the output of the compilation.
48 *
49 * See: http://webpack.github.io/docs/configuration.html#output
50 */
51 output: {
52 /**
53 * The output directory as absolute path (required).
54 *
55 * See: http://webpack.github.io/docs/configuration.html#output-path
56 */
57 path: helpers.root('dist'),
58 39
40 webpackMerge(commonConfig({ env: ENV }), {
59 /** 41 /**
60 * Specifies the name of each output file on disk. 42 * Developer tool to enhance debugging
61 * IMPORTANT: You must not specify an absolute path here!
62 * 43 *
63 * See: http://webpack.github.io/docs/configuration.html#output-filename 44 * See: http://webpack.github.io/docs/configuration.html#devtool
45 * See: https://github.com/webpack/docs/wiki/build-performance#sourcemaps
64 */ 46 */
65 filename: '[name].bundle.js', 47 devtool: 'cheap-module-source-map',
66 48
67 /** 49 /**
68 * The filename of the SourceMaps for the JavaScript files. 50 * Options affecting the output of the compilation.
69 * They are inside the output.path directory.
70 * 51 *
71 * See: http://webpack.github.io/docs/configuration.html#output-sourcemapfilename 52 * See: http://webpack.github.io/docs/configuration.html#output
72 */ 53 */
73 sourceMapFilename: '[name].map', 54 output: {
55 /**
56 * The output directory as absolute path (required).
57 *
58 * See: http://webpack.github.io/docs/configuration.html#output-path
59 */
60 path: helpers.root('dist'),
74 61
75 /** The filename of non-entry chunks as relative path 62 /**
76 * inside the output.path directory. 63 * Specifies the name of each output file on disk.
77 * 64 * IMPORTANT: You must not specify an absolute path here!
78 * See: http://webpack.github.io/docs/configuration.html#output-chunkfilename 65 *
79 */ 66 * See: http://webpack.github.io/docs/configuration.html#output-filename
80 chunkFilename: '[id].chunk.js', 67 */
81 68 filename: '[name].bundle.js',
82 library: 'ac_[name]',
83 libraryTarget: 'var'
84 },
85
86 module: {
87
88 // Too slow, life is short
89 // rules: [
90 // {
91 // test: /\.ts$/,
92 // use: [
93 // {
94 // loader: 'tslint-loader',
95 // options: {
96 // configFile: 'tslint.json'
97 // }
98 // }
99 // ],
100 // exclude: [
101 // /\.(spec|e2e)\.ts$/,
102 // /node_modules\//
103 // ]
104 // }
105 // ]
106 },
107
108 plugins: [
109 69
110 /** 70 /**
111 * Plugin: DefinePlugin 71 * The filename of the SourceMaps for the JavaScript files.
112 * Description: Define free variables. 72 * They are inside the output.path directory.
113 * Useful for having development builds with debug logging or adding global constants. 73 *
114 * 74 * See: http://webpack.github.io/docs/configuration.html#output-sourcemapfilename
115 * Environment helpers 75 */
116 * 76 sourceMapFilename: '[name].map',
117 * See: https://webpack.github.io/docs/list-of-plugins.html#defineplugin 77
118 */ 78 /** The filename of non-entry chunks as relative path
119 // NOTE: when adding more properties, make sure you include them in custom-typings.d.ts 79 * inside the output.path directory.
120 new DefinePlugin({ 80 *
121 'ENV': JSON.stringify(METADATA.ENV), 81 * See: http://webpack.github.io/docs/configuration.html#output-chunkfilename
122 'HMR': METADATA.HMR, 82 */
123 'API_URL': JSON.stringify(METADATA.API_URL), 83 chunkFilename: '[id].chunk.js',
124 'process.version': JSON.stringify(process.version), 84
125 'process.env': { 85 library: 'ac_[name]',
86 libraryTarget: 'var'
87 },
88
89 module: {
90
91 // Too slow, life is short
92 // rules: [
93 // {
94 // test: /\.ts$/,
95 // use: [
96 // {
97 // loader: 'tslint-loader',
98 // options: {
99 // configFile: 'tslint.json'
100 // }
101 // }
102 // ],
103 // exclude: [
104 // /\.(spec|e2e)\.ts$/,
105 // /node_modules\//
106 // ]
107 // }
108 // ]
109 },
110
111 plugins: [
112
113 /**
114 * Plugin: DefinePlugin
115 * Description: Define free variables.
116 * Useful for having development builds with debug logging or adding global constants.
117 *
118 * Environment helpers
119 *
120 * See: https://webpack.github.io/docs/list-of-plugins.html#defineplugin
121 */
122 // NOTE: when adding more properties, make sure you include them in custom-typings.d.ts
123 new DefinePlugin({
126 'ENV': JSON.stringify(METADATA.ENV), 124 'ENV': JSON.stringify(METADATA.ENV),
127 'NODE_ENV': JSON.stringify(METADATA.ENV), 125 'HMR': METADATA.HMR,
128 'HMR': METADATA.HMR 126 'API_URL': JSON.stringify(METADATA.API_URL),
129 } 127 'process.version': JSON.stringify(process.version),
130 }), 128 'process.env': {
131 129 'ENV': JSON.stringify(METADATA.ENV),
132 new DllBundlesPlugin({ 130 'NODE_ENV': JSON.stringify(METADATA.ENV),
133 bundles: { 131 'HMR': METADATA.HMR
134 polyfills: [ 132 }
135 'core-js', 133 }),
136 { 134
137 name: 'zone.js', 135 new DllBundlesPlugin({
138 path: 'zone.js/dist/zone.js' 136 bundles: {
137 polyfills: [
138 'core-js',
139 {
140 name: 'zone.js',
141 path: 'zone.js/dist/zone.js'
142 },
143 {
144 name: 'zone.js',
145 path: 'zone.js/dist/long-stack-trace-zone.js'
146 }
147 ],
148 vendor: [
149 '@angular/platform-browser',
150 '@angular/platform-browser-dynamic',
151 '@angular/core',
152 '@angular/common',
153 '@angular/forms',
154 '@angular/http',
155 '@angular/router',
156 '@angularclass/hmr',
157 'rxjs'
158 ]
159 },
160 dllDir: helpers.root('dll'),
161 webpackConfig: webpackMergeDll(commonConfig({env: ENV}), {
162 devtool: 'cheap-module-source-map',
163 plugins: []
164 })
165 }),
166
167 /**
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.
172 *
173 * See: https://github.com/SimenB/add-asset-html-webpack-plugin
174 */
175 new AddAssetHtmlPlugin([
176 { filepath: helpers.root(`dll/${DllBundlesPlugin.resolveFile('polyfills')}`) },
177 { filepath: helpers.root(`dll/${DllBundlesPlugin.resolveFile('vendor')}`) }
178 ]),
179
180 /**
181 * Plugin: NamedModulesPlugin (experimental)
182 * Description: Uses file names as module name.
183 *
184 * See: https://github.com/webpack/webpack/commit/a04ffb928365b19feb75087c63f13cadfc08e1eb
185 */
186 new NamedModulesPlugin(),
187
188 /**
189 * Plugin LoaderOptionsPlugin (experimental)
190 *
191 * See: https://gist.github.com/sokra/27b24881210b56bbaff7
192 */
193 new LoaderOptionsPlugin({
194 debug: true,
195 options: {
196
197 /**
198 * Static analysis linter for TypeScript advanced options configuration
199 * Description: An extensible linter for the TypeScript language.
200 *
201 * See: https://github.com/wbuchwalter/tslint-loader
202 */
203 tslint: {
204 emitErrors: false,
205 failOnHint: false,
206 typeCheck: true,
207 resourcePath: 'src'
139 }, 208 },
140 { 209
141 name: 'zone.js', 210 // FIXME: Remove
142 path: 'zone.js/dist/long-stack-trace-zone.js' 211 // https://github.com/bholloway/resolve-url-loader/issues/36
212 // https://github.com/jtangelder/sass-loader/issues/289
213 context: __dirname,
214 output: {
215 path: helpers.root('dist')
143 } 216 }
144 ], 217
145 vendor: [ 218 }
146 '@angular/platform-browser',
147 '@angular/platform-browser-dynamic',
148 '@angular/core',
149 '@angular/common',
150 '@angular/forms',
151 '@angular/http',
152 '@angular/router',
153 '@angularclass/hmr',
154 'rxjs'
155 ]
156 },
157 dllDir: helpers.root('dll'),
158 webpackConfig: webpackMergeDll(commonConfig({env: ENV}), {
159 devtool: 'cheap-module-source-map',
160 plugins: []
161 }) 219 })
162 }),
163 220
164 /** 221 ],
165 * Plugin: AddAssetHtmlPlugin
166 * Description: Adds the given JS or CSS file to the files
167 * Webpack knows about, and put it into the list of assets
168 * html-webpack-plugin injects into the generated html.
169 *
170 * See: https://github.com/SimenB/add-asset-html-webpack-plugin
171 */
172 new AddAssetHtmlPlugin([
173 { filepath: helpers.root(`dll/${DllBundlesPlugin.resolveFile('polyfills')}`) },
174 { filepath: helpers.root(`dll/${DllBundlesPlugin.resolveFile('vendor')}`) }
175 ]),
176 222
177 /** 223 /**
178 * Plugin: NamedModulesPlugin (experimental) 224 * Webpack Development Server configuration
179 * Description: Uses file names as module name. 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.
180 * 228 *
181 * See: https://github.com/webpack/webpack/commit/a04ffb928365b19feb75087c63f13cadfc08e1eb 229 * See: https://webpack.github.io/docs/webpack-dev-server.html
182 */ 230 */
183 new NamedModulesPlugin(), 231 devServer: {
232 port: METADATA.port,
233 host: METADATA.host,
234 historyApiFallback: true,
235 watchOptions: {
236 ignored: /node_modules/
237 }
238 },
184 239
185 /** 240 /*
186 * Plugin LoaderOptionsPlugin (experimental) 241 * Include polyfills or mocks for various node stuff
242 * Description: Node configuration
187 * 243 *
188 * See: https://gist.github.com/sokra/27b24881210b56bbaff7 244 * See: https://webpack.github.io/docs/configuration.html#node
189 */ 245 */
190 new LoaderOptionsPlugin({ 246 node: {
191 debug: true, 247 global: true,
192 options: { 248 crypto: 'empty',
193 249 fs: 'empty',
194 /** 250 process: true,
195 * Static analysis linter for TypeScript advanced options configuration 251 module: false,
196 * Description: An extensible linter for the TypeScript language. 252 clearImmediate: false,
197 * 253 setImmediate: false
198 * See: https://github.com/wbuchwalter/tslint-loader
199 */
200 tslint: {
201 emitErrors: false,
202 failOnHint: false,
203 typeCheck: true,
204 resourcePath: 'src'
205 },
206
207 // FIXME: Remove
208 // https://github.com/bholloway/resolve-url-loader/issues/36
209 // https://github.com/jtangelder/sass-loader/issues/289
210 context: __dirname,
211 output: {
212 path: helpers.root('dist')
213 }
214
215 }
216 })
217
218 ],
219
220 /**
221 * Webpack Development Server configuration
222 * Description: The webpack-dev-server is a little node.js Express server.
223 * The server emits information about the compilation state to the client,
224 * which reacts to those events.
225 *
226 * See: https://webpack.github.io/docs/webpack-dev-server.html
227 */
228 devServer: {
229 port: METADATA.port,
230 host: METADATA.host,
231 historyApiFallback: true,
232 watchOptions: {
233 ignored: /node_modules/
234 } 254 }
235 }, 255 }),
236 256
237 /* 257 videoEmbedConfig({env: ENV})
238 * Include polyfills or mocks for various node stuff 258 ]
239 * Description: Node configuration
240 *
241 * See: https://webpack.github.io/docs/configuration.html#node
242 */
243 node: {
244 global: true,
245 crypto: 'empty',
246 fs: 'empty',
247 process: true,
248 module: false,
249 clearImmediate: false,
250 setImmediate: false
251 }
252 })
253} 259}