Hi Guys,
I'm using the new version 5 template (.net core with jquery).
When i'm running the gulp --env prod command in my *.Web.Mvc folder, .min.js files are being generated in my /wwwroot/view-resources/areas/{name}/views/{name} folders. The min files are the same as the regular files though, the content is unminified Javascript.
I've specified the files to be minified in the bundle.config.js, like below:
{
outputFileName: "wwwroot/view-resources/Areas/App/Views/test/_CreateOrEditModal.min.js",
inputFiles: [
"wwwroot/view-resources/Areas/App/Views/test/_CreateOrEditModal.js"
]
}
What am I doing wrong here?
Thanks!
8 Answer(s)
-
0
@michelmk2 can you try "gulp --prod" ?
-
0
@ismcagdas. Nope! Same results. What's really strange is that it isn't working for the default items either.. E.g. ~wwwroot\view-resources\Views\Account\EmailActivation.min.js. Those min files are also just the regular files.
Greetings,
-
0
Can you add below pipe to your min:js task ? It will print out the error message if there is something wrong with existing files.
.on('error', function (error) { gutil.log(error.message); });
-
0
You mean, like this right?
gulp.task("min:js", function () { var tasks = getBundles(regex.js).map(function (bundle) { var outputFileName = getOutputFileName(bundle.outputFileName); var outputFolder = getOutputFolder(bundle.outputFileName); return gulp.src(bundle.inputFiles) .pipe(concat(outputFileName)) .pipe(gulp.dest(outputFolder)); }); if (gutil.env.prod) { var minifyTasks = getBundles(regex.js).map(function (bundle) { var outputFileName = getOutputFileName(bundle.outputFileName); var outputFolder = getOutputFolder(bundle.outputFileName); if (bundle.createMinified === false || outputFileName.endsWith('.min.js')) { return null; } var minifiedJsOutputFile = outputFileName.substr(0, outputFileName.lastIndexOf(".")) + ".min.js"; return gulp.src(bundle.inputFiles) .pipe(concat(minifiedJsOutputFile)) .pipe(uglify()) .pipe(gulp.dest(outputFolder)); }); for (var i = 0; i < minifyTasks.length; i++) { if (minifyTasks[i] == null) { continue; } tasks.push(minifyTasks[i]); } } return merge(tasks); }).on('error', function (error) { gutil.log(error.message); });
Unfortunately this doesn't give me any errors :(.
-
0
@michelmk2 can you send your project to us via email if it is not a problem for you ? We can find the problem faster in that way. You can use <a href="mailto:[email protected]">[email protected]</a>.
Thanks.
-
0
Hi @michelmk2, we resolved this issue.
Check related change: <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/commit/3c552b4648377d8216256af0b01b37564b44e2dd#diff-16281b32d0eef5f5b47ce3b2c590de12">https://github.com/aspnetzero/aspnet-ze ... b2c590de12</a>
-
0
<cite>alirizaadiyahsi: </cite> Hi @michelmk2, we resolved this issue.
Check related change: <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/commit/3c552b4648377d8216256af0b01b37564b44e2dd#diff-16281b32d0eef5f5b47ce3b2c590de12">https://github.com/aspnetzero/aspnet-ze ... b2c590de12</a>
Hi, Thanks for the link! What I see now, is that gulp generates *.min.min.js and *.min.min.css files. The min min files are no longered generated if I re-add the || outputFileName.endsWith('.min.js') line at the bundle.createMinified step. But then i'm back to my initial problem of the files not being minified :(.
Greetings
-
0
Ahh got it fixed! So what happens is that the last .js is trimmed of the output file names, and then .min.js is added. So that leaves you with .min.min.js.
Changing var minifiedJsOutputFile = outputFileName.substr(0, outputFileName.lastIndexOf(".")) + ".min.js"; to var minifiedJsOutputFile = outputFileName.substr(0, outputFileName.lastIndexOf(".")) + ".js";
And the same for css files, fixed the problem!
Thanks guys!