博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
grunt + sass 使用记录
阅读量:5239 次
发布时间:2019-06-14

本文共 3337 字,大约阅读时间需要 11 分钟。

环境依赖

  • Nodejs for grunt
  • Ruby for sass

配置文件

package.json

{  "name": "app",  "version": "1.0.0",  "devDependencies": {    "grunt": "^0.4.5",    "grunt-contrib-watch": "^0.6.1",    "grunt-contrib-sass": "^0.8.1",    "grunt-contrib-jshint": "^0.10.0",    "grunt-contrib-concat": "^0.5.0",    "grunt-contrib-cssmin": "^0.10.0",    "grunt-contrib-uglify": "^0.6.0",    "grunt-contrib-htmlmin": "^0.3.0",    "grunt-contrib-imagemin": "^0.9.2"  }}

 

Gruntfile.js

module.exports = function (grunt) {    // grunt config    grunt.initConfig({        pkg: grunt.file.readJSON('package.json'),        sass: {            options: {                style: 'expanded'            },            scss: {                files: [{                    src: 'src/css/main.scss',                    dest: 'src/css/main.css'                }]            }        },        jshint: {                        files: ['gruntfile.js', 'src/js/*.js']        },        concat: {            options: {                banner: '/*! <%= pkg.name %> <%= pkg.version %> <%= grunt.template.today("yyyy-mm-dd") %> */\n',                separator: '\n/*---------分割线---------*/\n'            },            js: {                files: [{                    src: ['src/js/base.js', 'src/js/script.js'],                    dest: 'dist/js/<%= pkg.name %>.js'                }]            }        },        cssmin: {            css: {                files: [{                    src: 'src/css/main.css',                    dest: 'dist/css/<%= pkg.name %>.min.css'                }]            }        },        uglify: {            js: {                files: [{                    src: 'dist/js/<%= pkg.name %>.js',                    dest: 'dist/js/<%= pkg.name %>.min.js'                }]            }        },        htmlmin: {            options: {                removeComments:true,                collapseWhitespace:true            },            dist: {                files: [{                    expand: true,       // all html                    cwd: 'src/',                    src: ['**/*.html'],                    dest: 'dist/'                }]            }        },        imagemin: {            img: {                files: [{                    expand: true,        // all images                    cwd: 'src/',                    src: ['**/*.{png,jpg,gif}'],                    dest: 'dist/'                }]            }        },        watch: {            css: {                files: 'src/css/main.scss',                tasks: ['sass']            },            js: {                files: ['<%= jshint.files %>'],                tasks: ['jshint']            }        }    });    // load task    grunt.loadNpmTasks('grunt-contrib-sass');    grunt.loadNpmTasks('grunt-contrib-jshint');    grunt.loadNpmTasks('grunt-contrib-concat');    grunt.loadNpmTasks('grunt-contrib-cssmin');    grunt.loadNpmTasks('grunt-contrib-uglify');    grunt.loadNpmTasks('grunt-contrib-htmlmin');    grunt.loadNpmTasks('grunt-contrib-imagemin');    grunt.loadNpmTasks('grunt-contrib-watch');    // regist task    grunt.registerTask('compile', ['watch']);    grunt.registerTask('default', ['sass', 'jshint', 'concat', 'cssmin', 'uglify']);    grunt.registerTask('html', ['htmlmin']);    grunt.registerTask('img', ['imagemin']);};

 

参考资源:

转载于:https://www.cnblogs.com/xiankui/p/4128305.html

你可能感兴趣的文章
转:基于InfluxDB&Grafana的JMeter实时性能测试数据的监控和展示
查看>>
结对编程博客
查看>>
Kendo MVVM 数据绑定(四) Disabled/Enabled
查看>>
python学习笔记3-列表
查看>>
程序的静态链接,动态链接和装载 (补充)
查看>>
关于本博客说明
查看>>
C++11 生产者消费者
查看>>
IO multiplexing 与 非阻塞网络编程
查看>>
hdu4105  Electric wave
查看>>
基于内容的图片检索CBIR(Content Based Image Retrieval)简介
查看>>
线程androidAndroid ConditionVariable的用法
查看>>
程序电脑VS2008 应用程序配置不正确,未能启动该应用程序。重新安装程序可以修复此问题。解决方法...
查看>>
设置类UIColor使用colorWithRed定义颜色
查看>>
文件语音识别Google语音识别学习札记 - Windows PC机上测试语音识别Strut2教程-java教程...
查看>>
μC/OS-III---I笔记13---中断管理
查看>>
:after,:before,content
查看>>
FTTB FTTC FTTH FTTO FSA
查看>>
OpenAI Gym
查看>>
stap-prep 需要安装那些内核符号
查看>>
网易杭研后台技术中心的博客 -MYSQL :OOM
查看>>