我使用 Yeoman 搭建我的网站。我想使用到目前为止工作一半的玉模板,我的玉文件作为 html 文件夹进入 tmp 并且 livereload 显示很好,但是当我运行 grunt 来构建我的站点时,文件夹 .tmp 中的 html 文件没有得到放入我的 public_html 文件夹。预期的所有其他文件夹/资产都将转到 public_html。
这是我的文件夹结构为糟糕的插图道歉:
站点名称
---- .sass 缓存
---- .tmp应用
---- bower_components
---- 图像
---- 玉
---- 脚本
---- 样式public_html
---- bower_components
---- 脚本
---- 样式// Generated on 2013-11-11 using generator-webapp 0.4.3 'use strict'; // # Globbing // for performance reasons we're only matching one level down: // 'test/spec/{,*/}*.js' // use this if you want to recursively match all subfolders: // 'test/spec/**/*.js' module.exports = function (grunt) { // show elapsed time at the end require('time-grunt')(grunt); // load all grunt tasks require('load-grunt-tasks')(grunt); grunt.initConfig({ // configurable paths site_name: { app: 'app', public_html: 'public_html' }, watch: { compass: { files: ['<%= site_name.app %>/styles/{,*/}*.{scss,sass}'], tasks: ['compass:server', 'autoprefixer'] }, styles: { files: ['<%= site_name.app %>/styles/{,*/}*.css'], tasks: ['copy:styles', 'autoprefixer'] }, jade: { files: ['<%= site_name.app %>/jade/{,*/}*.jade'], tasks: ['jade'] }, livereload: { options: { livereload: '<%= connect.options.livereload %>' }, files: [ '.tmp/{,*/}*.html', '.tmp/styles/{,*/}*.css', '{.tmp,<%= site_name.app %>}/scripts/{,*/}*.js', '<%= site_name.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}' ] } }, connect: { options: { port: 9000, livereload: 35729, // change this to '0.0.0.0' to access the server from outside hostname: 'localhost' }, livereload: { options: { open: true, base: [ '.tmp', '<%= site_name.app %>' ] } }, test: { options: { base: [ '.tmp', 'test', '<%= site_name.app %>' ] } }, public_html: { options: { open: true, base: '<%= site_name.public_html %>' } } }, clean: { public_html: { files: [{ dot: true, src: [ '.tmp', '<%= site_name.public_html %>/*', '!<%= site_name.public_html %>/.git*' ] }] }, server: '.tmp' }, jshint: { options: { jshintrc: '.jshintrc' }, all: [ 'Gruntfile.js', '<%= site_name.app %>/scripts/{,*/}*.js', '!<%= site_name.app %>/scripts/vendor/*', 'test/spec/{,*/}*.js' ] }, mocha: { all: { options: { run: true, urls: ['http://<%= connect.test.options.hostname %>:<%= connect.test.options.port %>/index.html'] } } }, compass: { options: { sassDir: '<%= site_name.app %>/styles', cssDir: '.tmp/styles', generatedImagesDir: '.tmp/images/generated', imagesDir: '<%= site_name.app %>/images', javascriptsDir: '<%= site_name.app %>/scripts', fontsDir: '<%= site_name.app %>/styles/fonts', importPath: '<%= site_name.app %>/bower_components', httpImagesPath: '/images', httpGeneratedImagesPath: '/images/generated', httpFontsPath: '/styles/fonts', relativeAssets: false, assetCacheBuster: false }, public_html: { options: { generatedImagesDir: '<%= site_name.public_html %>/images/generated' } }, server: { options: { debugInfo: true } } }, autoprefixer: { options: { browsers: ['last 1 version'] }, public_html: { files: [{ expand: true, cwd: '.tmp/styles/', src: '{,*/}*.css', dest: '.tmp/styles/' }] } }, // not used since Uglify task does concat, // but still available if needed /*concat: { public_html: {} },*/ 'bower-install': { app: { html: '<%= site_name.app %>/index.html', ignorePath: '<%= site_name.app %>/' } }, // not enabled since usemin task does concat and uglify // check index.html to edit your build targets // enable this task if you prefer defining your build targets here /*uglify: { public_html: {} },*/ rev: { public_html: { files: { src: [ '<%= site_name.public_html %>/scripts/{,*/}*.js', '<%= site_name.public_html %>/styles/{,*/}*.css', '<%= site_name.public_html %>/images/{,*/}*.{png,jpg,jpeg,gif,webp}', '<%= site_name.public_html %>/styles/fonts/{,*/}*.*' ] } } }, jade: { public_html: { options: { pretty: true }, files: [{ expand: true, cwd: '<%= site_name.app %>/jade', dest: '.tmp', src: '{,*/}*.jade', ext: '.html' }] } }, useminPrepare: { options: { dest: '<%= site_name.public_html %>' }, html: '<%= site_name.app %>/index.html' }, usemin: { options: { dirs: ['<%= site_name.public_html %>'] }, html: ['<%= site_name.public_html %>/{,*/}*.html'], css: ['<%= site_name.public_html %>/styles/{,*/}*.css'] }, imagemin: { public_html: { files: [{ expand: true, cwd: '<%= site_name.app %>/images', src: '{,*/}*.{png,jpg,jpeg}', dest: '<%= site_name.public_html %>/images' }] } }, svgmin: { public_html: { files: [{ expand: true, cwd: '<%= site_name.app %>/images', src: '{,*/}*.svg', dest: '<%= site_name.public_html %>/images' }] } }, cssmin: { // This task is pre-configured if you do not wish to use Usemin // blocks for your CSS. By default, the Usemin block from your // `index.html` will take care of minification, e.g. // // <!-- build:css({.tmp,app}) styles/main.css --> // // public_html: { // files: { // '<%= site_name.public_html %>/styles/main.css': [ // '.tmp/styles/{,*/}*.css', // '<%= site_name.app %>/styles/{,*/}*.css' // ] // } // } }, htmlmin: { public_html: { options: { /*removeCommentsFromCDATA: true, // https://github.com/murata/grunt-usemin/issues/44 //collapseWhitespace: true, collapseBooleanAttributes: true, removeAttributeQuotes: true, removeRedundantAttributes: true, useShortDoctype: true, removeEmptyAttributes: true, removeOptionalTags: true*/ }, files: [{ expand: true, cwd: '.tmp', src: '*.html', dest: '<%= site_name.public_html %>' }] } }, // Put files not handled in other tasks here copy: { public_html: { files: [{ expand: true, dot: true, cwd: '<%= site_name.app %>', dest: '<%= site_name.public_html %>', src: [ '*.{ico,png,txt}', '.htaccess', 'images/{,*/}*.{webp,gif}', 'styles/fonts/{,*/}*.*', 'bower_components/sass-bootstrap/fonts/*.*' ] }] }, styles: { expand: true, dot: true, cwd: '<%= site_name.app %>/styles', dest: '.tmp/styles/', src: '{,*/}*.css' } }, modernizr: { devFile: '<%= site_name.app %>/bower_components/modernizr/modernizr.js', outputFile: '<%= site_name.public_html %>/bower_components/modernizr/modernizr.js', files: [ '<%= site_name.public_html %>/scripts/{,*/}*.js', '<%= site_name.public_html %>/styles/{,*/}*.css', '!<%= site_name.public_html %>/scripts/vendor/*' ], uglify: true }, concurrent: { server: [ 'compass', 'copy:styles' ], test: [ 'copy:styles' ], public_html: [ 'compass', 'copy:styles', 'imagemin', 'svgmin', 'htmlmin' ] } }); grunt.registerTask('server', function (target) { if (target === 'public_html') { return grunt.task.run(['build', 'connect:public_html:keepalive']); } grunt.task.run([ 'clean:server', 'jade', 'concurrent:server', 'autoprefixer', 'connect:livereload', 'watch' ]); }); grunt.registerTask('test', [ 'clean:server', 'concurrent:test', 'autoprefixer', 'connect:test', 'mocha' ]); grunt.registerTask('build', [ 'clean:public_html', 'useminPrepare', 'concurrent:public_html', 'jade', 'autoprefixer', 'concat', 'cssmin', 'uglify', 'modernizr', 'copy:public_html', 'rev', 'usemin' ]); grunt.registerTask('default', [ /*'jshint',*/ 'test', 'build' ]);
};