1 | // webpack.dev.js - developmental builds |
||
2 | const LEGACY_CONFIG = 'legacy'; |
||
3 | const MODERN_CONFIG = 'modern'; |
||
4 | |||
5 | // node modules |
||
6 | const path = require('path'); |
||
7 | |||
8 | // webpack plugins |
||
9 | const merge = require('webpack-merge'); |
||
10 | const webpack = require('webpack'); |
||
11 | |||
12 | // config files |
||
13 | const pkg = require('./package.json'); |
||
14 | const common = require('./webpack.common.js'); |
||
15 | |||
16 | // Configure the webpack-dev-server |
||
17 | const configureDevServer = (buildType) => { |
||
18 | return { |
||
19 | contentBase: './web', |
||
20 | host: '0.0.0.0', |
||
21 | public: pkg.paths.dist.devPublic, |
||
22 | https: false, |
||
23 | hot: true, |
||
24 | hotOnly: true, |
||
25 | overlay: true, |
||
26 | stats: 'errors-only', |
||
27 | watchOptions: { |
||
28 | poll: true |
||
29 | }, |
||
30 | headers: { |
||
31 | 'Access-Control-Allow-Origin': '*' |
||
32 | } |
||
33 | }; |
||
34 | }; |
||
35 | |||
36 | // Postcss loader |
||
37 | const configurePostcssLoader = (buildType) => { |
||
38 | // Don't generate CSS for the legacy config in development |
||
39 | if (buildType === LEGACY_CONFIG) { |
||
40 | return { |
||
41 | test: /\.(pcss|css)$/, |
||
42 | loader: 'ignore-loader' |
||
43 | }; |
||
44 | } |
||
45 | if (buildType === MODERN_CONFIG) { |
||
0 ignored issues
–
show
|
|||
46 | return { |
||
47 | test: /\.(pcss|css)$/, |
||
48 | use: [ |
||
49 | { |
||
50 | loader: 'style-loader', |
||
51 | }, |
||
52 | { |
||
53 | loader: 'css-loader', |
||
54 | options: { |
||
55 | importLoaders: 2, |
||
56 | sourceMap: true |
||
57 | } |
||
58 | }, |
||
59 | { |
||
60 | loader: 'resolve-url-loader' |
||
61 | }, |
||
62 | { |
||
63 | loader: 'postcss-loader', |
||
64 | options: { |
||
65 | sourceMap: true |
||
66 | } |
||
67 | } |
||
68 | ] |
||
69 | }; |
||
70 | } |
||
71 | }; |
||
72 | |||
73 | // Development module exports |
||
74 | module.exports = [ |
||
75 | merge( |
||
76 | common.legacyConfig, |
||
77 | { |
||
78 | output: { |
||
79 | filename: path.join('./js', '[name]-legacy.[hash].js'), |
||
80 | publicPath: pkg.paths.dist.devPublic + '/', |
||
81 | }, |
||
82 | mode: 'development', |
||
83 | devtool: 'inline-source-map', |
||
84 | devServer: configureDevServer(LEGACY_CONFIG), |
||
85 | module: { |
||
86 | rules: [ |
||
87 | configurePostcssLoader(LEGACY_CONFIG), |
||
88 | ], |
||
89 | }, |
||
90 | plugins: [ |
||
91 | new webpack.HotModuleReplacementPlugin() |
||
92 | ], |
||
93 | } |
||
94 | ), |
||
95 | merge( |
||
96 | common.modernConfig, |
||
97 | { |
||
98 | output: { |
||
99 | filename: path.join('./js', '[name].[hash].js'), |
||
100 | publicPath: pkg.paths.dist.devPublic + '/', |
||
101 | }, |
||
102 | mode: 'development', |
||
103 | devtool: 'inline-source-map', |
||
104 | devServer: configureDevServer(MODERN_CONFIG), |
||
105 | module: { |
||
106 | rules: [ |
||
107 | configurePostcssLoader(MODERN_CONFIG), |
||
108 | ], |
||
109 | }, |
||
110 | plugins: [ |
||
111 | new webpack.HotModuleReplacementPlugin() |
||
112 | ], |
||
113 | } |
||
114 | ), |
||
115 | ]; |
||
116 |
This check looks for functions where a
return
statement is found in some execution paths, but not in all.Consider this little piece of code
The function
isBig
will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly returnundefined
.This behaviour may not be what you had intended. In any case, you can add a
return undefined
to the other execution path to make the return value explicit.