Comments (5)
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.
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.
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.
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.
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)
- can't remove HOT 8
- Is there a way to do wildcard file processing without inline HOT 2
- Allow the file type to be specified in options
- any way to set dest directory? HOT 6
- is there way to preprocess css files? HOT 3
- Source pattern with no extension will not traverse all files
- Sensitive to whitespace
- Support for grunt targets HOT 1
- @echo '-' not working HOT 1
- npm publish access HOT 1
- preprocess inside <script> tag on an HTML HOT 3
- Lacks on documentation. HOT 1
- Are prod:dev subkeys supported? HOT 1
- Please bump to preprocess 3.0.0 to allow recursive tags
- Multifile broken with 5.0.0
- optional tag for @include HOT 1
- Add 'type' option for multifiles HOT 1
- Support for lodash grunt templates in context and options HOT 1
- Can I use preprocess for targeting an app?
- Add a way to compare booleans
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grunt-preprocess.