How to configure Grunt to replace Bower dependencies by its minified versions

后端 未结 4 1938
栀梦
栀梦 2020-12-12 18:09

I am new to Yeoman/Grunt/Bower. I have a bower.json file that defines the following dependencies:

bower.json

{
    \"         


        
4条回答
  •  -上瘾入骨i
    2020-12-12 18:53

    Minified versions of the JavaScript libraries you're using will eventually not be shipped with Bower modules. Minifying and concatenating is not something the package manager is responsible for, but your build pipeline.

    With Yeoman, the recommended way is to use grunt-usemin, which will take care of all the necessary steps. You can see an example of this when scaffolding out a new app with yo webapp and taking a look at the generated Gruntfile.js and index.html.

    In your case, you would need to add a comment around your script includes:

    
    
    
    
    
    
    

    And make sure to have the corresponding usemin tasks in your Grunt pipeline:

    useminPrepare: {
        options: {
            dest: 'dist'
        },
        html: 'app/index.html'
    },
    usemin: {
        options: {
            dirs: ['dist']
        },
        html: ['dist/{,*/}*.html'],
        css: ['dist/styles/{,*/}*.css']
    },
    

提交回复
热议问题