gruntjs

How to compile a project properly with Babel and Grunt

你说的曾经没有我的故事 提交于 2019-12-03 01:41:14
问题 I'm trying to play with Babel, but it doesn't work well for me. My project is simple |-project/ |---src/ |-----index.html |-----main.js |-----module.js |---Gruntfile.js |---package.json index.html <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title>Test</title> <script src="main.js" type="application/javascript"></script> </head> <body> <p>Simple html file.</p> </body> </html> main.js import * as math from "./module"; async function anwser() { return 42; } (function main() {

How can I rename files with Grunt, based on the respective file's parent folder name?

随声附和 提交于 2019-12-03 01:35:37
问题 I have a the following structure: src/ modules/ module1/ js/ main.js scss/ main.scss index.html module2/ js/ main.js scss/ main.scss index.html I'd like to run a grunt task to copy these out to the following structure: dev/ js/ module1.js module2.js css/ module1.css module2.css module1.html module2.html Is there a way to do this with an existing grunt plugin? If not, how could I achieve this? 回答1: This can be done using the grunt-contrib-copy plugin. The main thing to note is that you can

Change link or script filename in html after gruntjs minify/uglify

痴心易碎 提交于 2019-12-03 01:24:34
I am using standard minify/uglify for css/js files and combine multiple files to main.min.css or app.min.js... However my .html file needs to be modified to point to these new file names too in <link> or <script> Is there a way to automate this? Or how to modify .html files automatically to rename the file names in there using gruntjs ? You can do this with grunt-string-replace . Here's an example on how you could use it. In my index.html you find the following import tags: <!--start PROD imports <script src="assets/dist/traffic.min.js"></script> end PROD imports--> <!--start DEV imports-->

grunt watch & connect

人走茶凉 提交于 2019-12-03 01:20:11
I am kinda new to grunt and want to use it with Jekyll and some LESS-compiling. My problem now is, I already have fully functioning LESS-comipiling with live reload and watch task and can build my jekyll site through grunt, but how do I run something like the jekyll serve or grunt-connect and grunt watch simultaneously? I want a grunt task that provides the watching of my LESS-files etc, builds the jekyll site and then runs a small web server with grunt-connect or whatever. My Gruntfile.js so far: 'use strict'; module.exports = function (grunt) { grunt.initConfig({ jshint: { options: {

Is there an injector like grunt-wiredep that works for NPM dependencies?

ぃ、小莉子 提交于 2019-12-03 01:17:45
Most packages nowadays are available in both NPM and Bower. I have to have NPM around, but I'd like cut Bower out of the loop on my project. I'm currently relying on grunt-wiredep to create <script> includes in my index.html . This tool looks at all of the Bower configs to pull all the necessary js and css files into my index.html for me. Is there a tool that will do the same for NPM dependencies? You would be able to do that using a module bundler like Browserify or Webpack . For getting started with Browserify , you will need to first install it via NPM globally npm install -g browserify

How to compile .sass files on save in Visual Studio 2015

两盒软妹~` 提交于 2019-12-03 01:08:09
问题 How can one get a full sass (i.e. scss) precompiler environment up and running in Visual Studio 2015? This is a sibling question to this one concerning less. 回答1: If using Gulp + Visual Studio 2015 First install gulp-sass this is the package.json file { "name": "ASP.NET", "version": "0.0.0", "devDependencies": { "gulp": "3.8.11", "gulp-concat": "2.5.2", "gulp-cssmin": "0.1.7", "gulp-uglify": "1.2.0", "rimraf": "2.2.8", "gulp-sass": "2.2.0" } On the gulpfile.js var sass = require("gulp-sass");

Automate npm and bower install with grunt

落花浮王杯 提交于 2019-12-03 00:18:13
问题 I have a node / angular project that uses npm for backend dependency management and bower for frontend dependency management. I'd like to use a grunt task to do both install commands. I haven't been able to figure out how to do it. I made an attempt using exec , but it doesn't actually install anything. module.exports = function(grunt) { grunt.registerTask('install', 'install the backend and frontend dependencies', function() { // adapted from http://www.dzone.com/snippets/execute-unix

Cannot use grunt on simple Yeoman angular

人盡茶涼 提交于 2019-12-03 00:17:48
Trying to just startup a simple angular app via Yeoman, using steps in this guide http://www.sitepoint.com/kickstart-your-angularjs-development-with-yeoman-grunt-and-bower/ and get this error when trying to run grunt or grunt server : Loading "Gruntfile.js" tasks...ERROR Error: Cannot find module 'load-grunt-tasks' Warning: Task "default" not found. Use --force to continue. Here are my versions: yo --version && grunt --version && bower --version 1.1.2< grunt-cli v0.1.13 grunt v0.4.4 1.3.1 See screencast of this in action: http://screencast.com/t/4ToPw3SlL2 I just encountered the same problem

How do I run grunt from a different folder than my root project

╄→尐↘猪︶ㄣ 提交于 2019-12-02 23:27:31
Is there a way to tell grunt which grunt.js file to use? I have an f:\a\b\tools folder that contains grunt.cmd, node.exe,... , my actual web app with GruntFile.js and all the local node_modules is in f:\a\c\my_app Running grunt from a\c\my_app works fine but trying to run grunt from some other folder say a does not seem to work. I am new to grunt and may be I am missing something obvious. f:\a>grunt --config c\GruntFile.js grunt-cli: The grunt command line interface. (v0.1.6) Fatal error: Unable to find local grunt. If you're seeing this message, either a Gruntfile wasn't found or grunt hasn't

How do I remove some javascript during grunt-usemin compilation

不打扰是莪最后的温柔 提交于 2019-12-02 23:17:59
I have code that makes it easy and fast to write/test code, that code does not belong in my production code (mostly it mocks out the server so I only need the grunt server). Two parts to this, one is how to I remove parts of a script angular.module('nglaborcallApp', [ 'ngCookies', 'ngResource', 'ngSanitize', 'ngRoute', 'server_mocks', // Don't want this line in the production build 'dialogs' ] and then a section of index.html that needs to go away <!-- build:js({.tmp,app}) scripts/mocks/mocks.js --> <script type='text/javascript'>var Mocks = {};</script> <script src='scripts/mocks/jobs.js'><