|
1 | 1 | /* |
2 | 2 | * Webpack is used to compile and minify/uglify JS and Sass. |
3 | | - * Since this will nuke some of the directories inside the public directory, |
| 3 | + * Since this will nuke some directories inside the public directory, |
4 | 4 | * you should no longer manually add images etc. to the public folder. |
5 | 5 | * We have set up a configuration that will automatically copy any image |
6 | 6 | * from the images folder here to public/images/{moduleName}. |
@@ -50,8 +50,8 @@ const { CleanWebpackPlugin } = require('clean-webpack-plugin'); |
50 | 50 | const MiniCssExtractPlugin = require("mini-css-extract-plugin"); |
51 | 51 | const TerserPlugin = require('terser-webpack-plugin'); |
52 | 52 |
|
53 | | -// Prepare plugin to extract styles into a css file |
54 | | -// instead of a javascript file |
| 53 | +// Prepare plugin to extract styles into a CSS file |
| 54 | +// instead of a JavaScript file |
55 | 55 |
|
56 | 56 | // dynamically build webpack entries based on registered app modules |
57 | 57 | let entries = { |
@@ -96,26 +96,37 @@ appModules.forEach(function (appModule) { |
96 | 96 | } |
97 | 97 | }); |
98 | 98 |
|
| 99 | +Object.keys(entries).forEach(function (name) { |
| 100 | + if (name === 'app') { |
| 101 | + return; |
| 102 | + } |
| 103 | + |
| 104 | + entries[name] = { |
| 105 | + import: entries[name], |
| 106 | + dependOn: 'app', |
| 107 | + }; |
| 108 | +}); |
| 109 | + |
99 | 110 | /* |
100 | 111 | * Lastly, export the final module |
101 | 112 | * and the assets |
102 | 113 | */ |
103 | 114 | module.exports = { |
104 | 115 | // This is the basepath for Webpack to look for source files |
105 | | - // if you need to include modules outside of the App module, |
| 116 | + // if you need to include modules outside the App module, |
106 | 117 | // move the "/App/assets" portion of the context onto the two |
107 | 118 | // strings below, so it becomes "./App/assets/js/app.js" etc. |
108 | 119 | context: path.resolve(__dirname, './src'), |
109 | 120 |
|
110 | 121 | // These are our entry files, this is the files Webpack will use |
111 | | - // when looking for Sass and Javascript to compile. |
| 122 | + // when looking for Sass and JavaScript to compile. |
112 | 123 | // The format is "DESTINATION": "SOURCE", and each path is |
113 | 124 | // relative to the output path and the context respectively. |
114 | 125 | entry: entries, |
115 | 126 |
|
116 | 127 | // The Output is where Webpack will export our files to |
117 | 128 | // the filename will be resolved to the key in the entry object above. |
118 | | - // The publicPath is what it'll rewrite css relative urls to use. |
| 129 | + // The publicPath is what it'll rewrite CSS relative urls to use. |
119 | 130 | // The path is where it'll save files too |
120 | 131 | output: { |
121 | 132 | filename: './js/[name].js', |
@@ -236,7 +247,7 @@ function generateBaseRules() |
236 | 247 | test: /\.(woff|woff2|eot|ttf|otf|svg)$/, |
237 | 248 | exclude: [/images?|img/], |
238 | 249 | use: [ |
239 | | - // As SVG may count as both font or image |
| 250 | + // As SVG may count as both font or image, |
240 | 251 | // we will not treat any file in a folder |
241 | 252 | // with the name image(s) or img as a font |
242 | 253 | 'file-loader?name=fonts/[name].[ext]' |
|
0 commit comments