Hello, I am currently working on setting up a Grunt runner to run my project from the dist folder. Below is the code snippet from my Gruntfile.js:
'use strict';
module.exports = function(grunt) {
// Time how long tasks take. Can help when optimizing build times
require('time-grunt')(grunt);
// Automatically load required Grunt tasks
require('jit-grunt')(grunt, {
useminPrepare: 'grunt-usemin'
});
// Define the configuration for all tasks
grunt.initConfig({
// Task configurations here
});
// Registering tasks
grunt.registerTask('css', ['sass']);
grunt.registerTask('default', ['browserSync', 'watch']);
grunt.registerTask('build', [
'clean',
'copy',
'imagemin',
'useminPrepare',
'concat',
'cssmin',
'uglify',
'filerev',
'usemin',
'htmlmin'
]);
}
After running grunt build
in the terminal, I encountered an error while trying to access the project through http://localhost:3000/dist/index.html. The browser console displayed several MIME type errors and failed to load some JavaScript files. This issue seems to stem from incorrect minification of node_module js files into the dist folder.
If you have any insights on how to resolve this error, please feel free to share. You can also find my repository here.
Thank you, Theo