I have a basic project with several js files and several css files
I would like them to be reduced to one js and one css
So far I have managed to merge and minimize my entire js file to one main.min.js
Now I am trying to do the same with css files
this is my layout:
css bootstrap.css docs.css ... js optimize-node (script to run the optimizer) app main.js (entry point of my app) require-main.js index.html
this is my script to minimize it
this is my require-main.js
'use strict'; // Set the require.js configuration file for your application require.config({ // uncomment to create a single file with no optimization at all // optimize: 'none', baseUrl: 'js', // Initialize the application with the main application file deps : ['app/main'], preserveLicenseComments: false, out : 'main.min.js', name : 'app/main', paths: { // Embed require in main.min 'requireLib' : 'lib/require.min', // Libraries jquery : 'lib/jquery-1.10.1', jqueryui : 'lib/jquery-ui-1.8.21.custom', moment : 'lib/moment-2.0.0', datepicker : 'lib/bootstrap-datepicker-1.0.1', [...] }, include : ['requireLib'], shim: { lodash: { exports: '_' }, backbone: { deps : ['lodash', 'jquery'], exports : 'Backbone' }, [...] } });
with this configuration, when I run optimize-node, everything works fine and the js / app / main.min.js file is created
Now I am trying to change the configuration to generate this file, as well as the css / main.min.css file with the contents of css / *. css concatenated and reduced
I tried replacing these lines
// single file optimization out : 'main.min.js', name : 'app/main',
with this configuration to define two modules: one for js and another for css
// multiple file optimization dir: '../../build', appDir: '../', modules: [ { name: 'app/main', include: ['app/main'] } ],
But it does not work properly
My whole project is copied to .. /../build, and each file is optimized
And I do not know how to add another module that will simply select css files
Perhaphs I have to create a require-css.js file that just takes care of the css / *. Css files
Can someone help me? I think this should be a fairly common scenario.