If you use require or ES56 import to grab files, no...you don't have to tell Webpack the order. Webpack connects everything when processing the file.Although, there are occasions when you run into a small issue with order. A way to solve that is to chunk the files or declare the require early or attach to the window if possible.
Feb 18, 2017
3
Level 5
Webpack compile order
So, with gulp I used to import / required my dependencies in app.js and app.scss like so:
require('./bootstrap');
require('admin-lte/dist/js/app.js');
require('jquery-form-validator/form-validator/jquery.form-validator.min.js');
require('jquery-form-validator/form-validator/security.js');
// Imported stylesheets
@import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap";
@import "node_modules/admin-lte/dist/css/AdminLTE";
@import "node_modules/admin-lte/dist/css/skins/_all-skins";
@import "node_modules/font-awesome/css/font-awesome";
@import "node_modules/jquery-form-validator/src/theme-default";
@import "node_modules/simplemde/dist/simplemde.min";
// Custom stylesheets
@import "custom";
And in the gulp file I did:
elixir(mix => {
mix.sass('app.scss')
.webpack('app.js');
});
That would compile the files in the order, that they were required and imported, giving the correct order.
However, with webpack, the same thing does not apply. The output with webpack is:
[11] ./resources/assets/js/app.js 748 bytes {0} [built]
[12] ./resources/assets/sass/app.scss 41 bytes {0} [built]
[13] ./~/admin-lte/dist/js/app.js 23.3 kB {0} [built]
[14] ./~/axios/index.js 40 bytes {0} [built]
[33] ./resources/assets/js/bootstrap.js 1.36 kB {0} [built]
[35] ./~/jquery-form-validator/form-validator/jquery.form-validator.js 75.7 kB {0} [built]
[36] ./~/jquery-form-validator/form-validator/security.js 9.65 kB {0} [built]
[43] multi ./resources/assets/js/app.js ./resources/assets/sass/app.scss 40 bytes {0} [built]
[46] ./~/css-loader?sourceMap!./~/font-awesome/css/font-awesome.css 101 kB [built]
[47] ./~/css-loader?sourceMap!./~/jquery-form-validator/src/theme-default.css 129 kB [built]
[48] ./~/css-loader?sourceMap!./~/postcss-loader?sourceMap!./~/resolve-url-loader?sourceMap!./~/sass-loader?{"precision":8,"outputStyle":"expanded"}!./resources/assets/sass/app.scss 365 kB [built]
[54] ./~/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.ttf 92 bytes [built]
[55] ./~/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.woff 93 bytes [built]
[56] ./~/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.woff2 94 bytes [built]
With webpack the configuration looks like this:
mix.js('resources/assets/js/app.js', 'public/js')
.sass('resources/assets/sass/app.scss', 'public/css');
Do I really need to tell webpack which order I need the files in or is this some kind of issue with the compiler?
Please or to participate in this conversation.