Giter Site home page Giter Site logo

Doesn't preprocess about grunt-preprocess HOT 5 CLOSED

nwmcsween avatar nwmcsween commented on July 23, 2024
Doesn't preprocess

from grunt-preprocess.

Comments (5)

jsoverson avatar jsoverson commented on July 23, 2024

That is not the correct syntax for the directives.

<!-- @if ENV='dev' -->
foo
<!-- @endif -->

or conditional comment syntax

<!-- @if ENV='rel' !>
foo
<!-- @endif -->

This task also delegates to preprocess, so if you find this is still a problem, please open an issue there.

from grunt-preprocess.

nwmcsween avatar nwmcsween commented on July 23, 2024

I fixed the syntax but I'm still hitting an issue on this, doing a ENV=rel grunt preprocess produces expected output but a ENV=rel grunt with preprocess in default taskset does not.

grunt.registerTask('build', ['preprocess', 'coffee', 'less'])
...
grunt.registerTask('default', ['build', 'optimize', 'install', 'check', 'test', 'test:e2e'])

from grunt-preprocess.

jsoverson avatar jsoverson commented on July 23, 2024

Isolate the preprocess in the default list to make sure that works with grunt. If that does, then do you have anything overwriting the preprocessed files?

from grunt-preprocess.

nwmcsween avatar nwmcsween commented on July 23, 2024

Nothing I can see and preprocess in default taskset does the same thing the env var ENV isn't being passed or is overwritten if invoked via grunt default vs grunt preprocess

config = hierarchy:
    build:  'build'
    source: 'source'
    client: 'client'
    server: 'server'
    static: 'static'

module.exports = (grunt) ->

#   config  = require('./config/config.coffee')
    md = require('matchdep')

    grunt.loadNpmTasks(p) for p in md.filter('grunt-*')

    grunt.registerTask('build', ['preprocess', 'coffee', 'less'])
    grunt.registerTask('optimize', ['imagemin', 'uglify'])
    grunt.registerTask('install', ['symlink', 'copy'])
    grunt.registerTask('check', ['lesslint', 'coffeelint', 'complexity'])
    grunt.registerTask('test', ['test:unit'])
    grunt.registerTask('test:unit', ['karma:unit'])
    grunt.registerTask('test:e2e', ['karma:e2e'])
    grunt.registerTask('default', [ 'build', 'optimize', 'install', 'check', 'test', 'test:e2e'])
    grunt.registerTask('dev', ['connect', 'watch'])

    grunt.registerTask('printenv', ->
        console.log(process.env))

    re = new RegExp("(#{config.hierarchy.source}|#{config.hierarchy.build}|#{config.hierarchy.static})")
    inBuild = (f) ->
        grunt.file.isFile(f.replace(re, "#{config.hierarchy.build}"))

    # Configuration
    grunt.initConfig

        clean: ["#{config.hierarchy.build}/**/*", "#{config.hierarchy.static}/**/*"]

        coffee:
            source:
                files: [
                    expand: true
                    cwd:    "#{config.hierarchy.source}"
                    src:    '**/*.coffee'
                    dest:   "#{config.hierarchy.build}"
                    ext:    '.js'
                    filter: 'isFile'
                ]

        coffeelint:
            options:
                indentation:
                    value: 4
            src: "#{config.hierarchy.source}/**/*.coffee"

        complexity:
            options:
                cyclomatic:         3
                halstead:           11
                maintainability:    100
            static:
                files: [
                    src:    ["#{config.hierarchy.static}/**/*.js",
                        "!#{config.hierarchy.static}/#{config.hierarchy.client}/vendor/**/*"]
                    filter: 'isFile'
                ]

        connect:
            server:
                options:
                    hostname: '*'
                    port:   8080
                    base:   "#{config.hierarchy.static}/#{config.hierarchy.client}"

        copy:
            source:
                files: [
                    expand: true
                    cwd:    "#{config.hierarchy.source}"
                    src:    ['**/*', '!**/*.{coffee,less}']
                    dest:   "#{config.hierarchy.static}"
                    filter: !inBuild
                ]

        imagemin:
            options:
                progressive:    false
                interlaced:     false
                pngquant:       false
            source:
                files: [
                    expand: true
                    cwd:    "#{config.hierarchy.source}"
                    src:    "**/*.{png,gif,jpg,jpeg}"
                    dest:   "#{config.hierarchy.build}"
                ]

        karma:
            source:
                client:
                    options:
                        configFile: 'config/karam.js'
                    background:
                        background: true
                        singleRun:  false
                    e2e:
                        browsers:   ['PhantomJS']
                        singleRun:  true
                    unit:
                        singleRun:  true

        less:
            source:
                files: [
                    expand: true
                    cwd:    "#{config.hierarchy.source}"
                    src:    '**/*.less'
                    dest:   "#{config.hierarchy.build}"
                    ext:    '.css'
                    filter: 'isFile'
                ]

        lesslint:
            options:
                csslint:
                    'adjoining-classes': false
            source:
                files: [
                    src:    "#{config.hierarchy.source}/**/*.less"
                    filter: 'isFile'
                ]

#       ngmin:
#           build:
#               expand: true
#               cwd:    "#{config.hierarchy.build}"
#               src:    "#{config.hierarchy.client}/**/*.js"
#               dest:   "#{config.hierarchy.build}"
#               filter: 'isFile'

        preprocess:
            source:
                files: [
                    expand: true
                    cwd:    "#{config.hierarchy.source}"
                    src:    '**/*.html'
                    dest:   "#{config.hierarchy.build}"
                    filter: 'isFile'
                ]


# TODO: sprtie-smith

        symlink:
            build:
                files: [
                    expand: true
                    cwd:    "#{config.hierarchy.build}"
                    src:    "**/*"
                    dest:   "#{config.hierarchy.static}"
                    filter: 'isFile'
                ]
            components:
                files: [
                    expand: true
                    cwd:    'bower_components'
                    src:    '**/*'
                    dest:   "#{config.hierarchy.static}/#{config.hierarchy.client}/vendor"
                    filter: 'isFile'
                ]

        uglify:
            options:
                compress:       true
                sequences:      true
                properties:     true
                dead_code:      true
                unsafe:         true
                conditionals:   true
                comparisons:    true
                evaluate:       true
                booleans:       true
                loop:           true
                unused:         true
                houst_funs:     true
                if_return:      true
                join_vars:      true
                cascade:        true
                warnings:       true
                negate_iife:    true
            source:
                files: [
                    expand: true
                    cwd:    "#{config.hierarchy.build}"
                    src:    '**/*.js'
                    dest:   "#{config.hierarchy.build}"
                ]

        watch:
            options:
                debounceDelay:  200
                livereload:     true
                nospawn:        true
            coffee:
                files: ["#{config.hierarchy.source}/**/*.coffee"]
                tasks: ['coffeelint', 'coffee']
            image:
                files: ["#{config.hierarchy.source}/**/*.{png,gif,jpg,jpeg}"]
                tasks: ['imagemin']
            js:
                files: ["#{config.hierarchy.build}/**/*.js"]
                tasks: ['uglify']
            less:
                files: ["#{config.hierarchy.source}/**/*.less"]
                tasks: ['lesslint', 'less']
            link:
                files: ["#{config.hierarchy.build}'**/*"]
                tasks: ['symlink']
            unit:
                files: ["#{config.hierarchy.static}/#{config.hierarchy.client}/tests/**/*"]
                tasks: ['karma:source:client:background:run']

from grunt-preprocess.

jsoverson avatar jsoverson commented on July 23, 2024

Just double checked on my machine and all looks well, posting to confirm.

[joverson@joverson-riot:~/temp/pp]
[10:01:44] $ ENV=dev grunt && cat done.html
Running "preprocess:main" (preprocess) task

Done, without errors.
HTML START
----------
Only shows if dev
----------

[joverson@joverson-riot:~/temp/pp]
[10:01:47] $ ENV=rel grunt && cat done.html
Running "preprocess:main" (preprocess) task

Done, without errors.
HTML START
----------
Only shows if rel
----------

[joverson@joverson-riot:~/temp/pp]
[10:01:52] $ ENV=dev grunt preprocess && cat done.html
Running "preprocess:main" (preprocess) task

Done, without errors.
HTML START
----------
Only shows if dev
----------

[joverson@joverson-riot:~/temp/pp]
[10:01:59] $ ENV=rel grunt preprocess && cat done.html
Running "preprocess:main" (preprocess) task

Done, without errors.
HTML START
----------
Only shows if rel
----------

Gruntfile :

module.exports = function(grunt) {

  grunt.initConfig({
    preprocess : {
      main : { src : 'index.html', dest : 'done.html' }
    }
  });

  grunt.loadNpmTasks('grunt-preprocess')

  grunt.registerTask('default', ['preprocess']);

};

index.html

HTML START
----------
<!-- @if ENV='dev' -->
Only shows if dev
<!-- @endif -->

<!-- @if ENV='rel' !>
Only shows if rel
<!-- @endif -->
----------

If you find out the issue, please update the ticket. There's not much I can do to troubleshoot from my end. I'd recommend limiting as much as possible to isolate the variables and then testing configurations to find out what is broken.

from grunt-preprocess.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.