browserify-shim not finding module - browserify

Given the following:
main.js
var angular = require('angular');
package.json
{
"main": "./main.js",
"browser": {
"angular": "./vendor/angular/angular.js"
},
"browserify-shim": {
"angular": "angular"
},
"browserify": {
"transform": [ "browserify-shim" ]
},
"dependencies": {
"browserify-shim": "~3.2.0"
}
}
When running:
browserify . -d -o bundle.js
A bundle is successfully created and the output from the browserify-shim diagnostics is:
{
file: 'D:\\development\\js\\browserify\\main.js',
info:
{
package_json: 'D:\\development\\js\\browserify\\package.json',
packageDir: 'D:\\development\\js\\browserify',
shim: undefined,
exposeGlobals:
{},
browser:
{
angular: './vendor/angular/angular.js'
},
'browserify-shim':
{
angular: 'angular'
},
dependencies:
{
'browserify-shim': '~3.2.0'
},
lookedUp: false
},
messages: ['Found "angular" in browser field referencing "./vendor/angular/angular.js" and resolved it to "D:\\development\\js\\browserify\\vendor\\angular\\angular.js"',
{
resolved:
{
'D:\\development\\js\\browserify\\vendor\\angular\\angular.js':
{
exports: 'angular',
depends: undefined
}
}
}]
}
{
file: 'D:\\development\\js\\browserify\\vendor\\angular\\angular.js',
info:
{
package_json: 'D:\\development\\js\\browserify\\package.json',
packageDir: 'D:\\development\\js\\browserify\\',
shim:
{
exports: 'angular',
depends: undefined
},
exposeGlobals:
{},
browser:
{
angular: './vendor/angular/angular.js'
},
'browserify-shim':
{
angular: 'angular'
},
dependencies:
{
'browserify-shim': '~3.2.0'
},
lookedUp: false
},
messages: ['Found "angular" in browser field referencing "./vendor/angular/angular.js" and resolved it to "D:\\development\\js\\browserify\\vendor\\angular\\angular.js"',
{
resolved:
{
'D:\\development\\js\\browserify\\vendor\\angular\\angular.js':
{
exports: 'angular',
depends: undefined
}
}
}]
}
If package.json is changed to this (removing the browser section):
{
"main": "./main.js",
"browserify-shim": {
"./vendor/angular/angular.js": "angular"
},
"browserify": {
"transform": [ "browserify-shim" ]
},
"dependencies": {
"browserify-shim": "~3.2.0"
}
}
I get the following error:
Error: module "angular" not found from "D:\\development\\js\\browserify\\main.js"
With the output from browserify-shim diagnostics as:
{
file: 'D:\\development\\js\\browserify\\main.js',
info:
{
package_json: 'D:\\development\\js\\browserify\\package.json',
packageDir: 'D:\\development\\js\\browserify',
shim: undefined,
exposeGlobals:
{},
browser: undefined,
'browserify-shim':
{
'./vendor/angular/angular.js': 'angular'
},
dependencies:
{
'browserify-shim': '~3.2.0'
},
lookedUp: false
},
messages: ['Resolved "./vendor/angular/angular.js" found in package.json to "D:\\development\\js\\browserify\\vendor\\angular\\angular.js"',
{
resolved:
{
'D:\\development\\js\\browserify\\vendor\\angular\\angular.js':
{
exports: 'angular',
depends: undefined
}
}
}]
}
{
[Error: module "angular"
not found from "D:\\development\\js\\browserify\\main.js"
]
filename: 'angular',
parent: 'D:\\development\\js\\browserify\\main.js'
}
I was under the impression that the browser section was for configuring aliases and that the two different package.json files above should be equivalent.
Have I misunderstood?

From the author:
If you don't alias ./vendor/angular/angular.js to angular via the browser field, browserify doesn't know where to find it.
So if you omit the browser field alias please do:
var angular = require('./vendor/angular/angular.js');
( assuming that ./vendor/angular/angular.js is relative to where you are requiring it from )

Related

Nuxt, Vue, RefreshToken => Uncaught (in promise) TypeError: Cannot read property 'protocol' of undefined => Axios plugin, Axios Interceptors

my goal is to refresh the token after catching the 401 status code and the "token expired" message in my interceptor on the response ...
What are they doing wrong?
I'm using nuxt, vue, axios. Please help!
Uncaught (in promise) TypeError: Cannot read property 'protocol' of
undefined
it sends me back to that code:
#/plugins/axios.js:
import Vue from 'vue';
import axios from 'axios';
axios.interceptors.response.use((response) => {
console.debug("AXIOS.JS plugin => response: ", response);
return response;
}, function (error) {
console.debug("AXIOS.JS plugin => error: ", error);
return Promise.reject(error);
});
Vue.use(axios);
package.json:
{
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate"
},
"dependencies": {
"#nuxtjs/axios": "^5.13.1",
"#nuxtjs/composition-api": "^0.24.7",
"#nuxtjs/dotenv": "^1.4.1",
"#nuxtjs/proxy": "^2.1.0",
"#nuxtjs/pwa": "^3.3.5",
"#vue/composition-api": "^1.0.0-rc.13",
"core-js": "^3.9.1",
"nuxt": "^2.15.6",
"vue-multiselect": "^2.1.6",
"vue2-datepicker": "^3.9.1"
},
"devDependencies": {
"#nuxtjs/tailwindcss": "^4.1.2",
"autoprefixer": "^10.2.5",
"postcss": "^8.3.0",
"tailwindcss": "^2.1.2"
}
}
nuxt.config.js
const routes = require('./routes/index.js')
export default {
// Global page headers: https://go.nuxtjs.dev/config-head
head: {
title: 'Fokser',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: '' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
],
script: [
{
//src: "https://skrypt-cookies.pl/id/d6458d5064c23515.js",
//src: "https://skrypt-cookies.pl/id/69205d8cab854dc2.js",
body: true,
},
],
},
// Global CSS: https://go.nuxtjs.dev/config-css
css: [
'#/static/css/styles.css',
],
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
plugins: [
{
src: "#/plugins/filters.js",
src: "#/plugins/axios.js",
}
],
// Auto import components: https://go.nuxtjs.dev/config-components
components: true,
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
buildModules: [
// https://go.nuxtjs.dev/tailwindcss
'#nuxtjs/tailwindcss',
'#nuxtjs/composition-api/module'
],
// Modules: https://go.nuxtjs.dev/config-modules
modules: [
// https://go.nuxtjs.dev/axios
'#nuxtjs/axios',
// https://go.nuxtjs.dev/pwa
'#nuxtjs/pwa',
'#nuxtjs/proxy',
'#nuxtjs/dotenv'
],
// Axios module configuration: https://go.nuxtjs.dev/config-axios
axios: {
proxy: true
},
// PWA module configuration: https://go.nuxtjs.dev/pwa
pwa: {
manifest: {
lang: 'en'
}
},
// Build Configuration: https://go.nuxtjs.dev/config-build
build: {
},
proxy: {
'/api/': {
target: process.env.VUE_APP_ROOT_API,
pathRewrite: { '^/api': '' }
}
},
router: {
extendRoutes(nuxtRoutes, resolve) {
routes.forEach((route) => {
nuxtRoutes.push({
name: route.name,
path: route.path,
component: resolve(__dirname, route.component)
})
})
}
}
}
This occurs at main page (localhost):
besides, I am making a request to api like:
loadUserInfo({ commit }) {
let token = localStorage.getItem("auth_token");
let userId = localStorage.getItem("id");
commit("setUserToken", token);
commit("setUserId", userId);
if (userId && token) {
this.$axios.get(`api/accounts/userName/${userId}`)
.then((res) => {
if (res.status === 200) {
commit("setUserName", res.data.userName);
}
})
.catch(err => {
console.debug("[authorize.js LoadUserInfo], errors: ", err);
})
}
},
async getRecords({commit}, request) {
let config = {
params: {
recordType: request.recordType,
limit: limit
},
}
return await this.$axios.get(`/api/records/getRecords`, config);
}
loadAll({ commit }, request) {
this.$axios.get(`/api/records/all`, request)
.then((res) => {
if (res.status === 200) {
commit('setRecords', res.data);
}
});
},
I don't know where is the problem... :(

Module not found: Error: Can't resolve '#babylonjs/core/Engines/engine'

I am following a guide to setup a simple BabylonJs example with npm, webpack, typescript and ES6 (https://doc.babylonjs.com/divingDeeper/developWithBjs/npmSupport) and get the following error when running npm run build:
ERROR in ./index.ts 3:17-58
Module not found: Error: Can't resolve '#babylonjs/core/Engines/engine' in 'C:\...\BabylonJSPlayground\HelloWorld'
... same error for other modules in #babylonjs/core
My npm installations:
npm init
npm install --save-dev webpack webpack-cli typescript ts-loader
npm install --save #babylonjs/core #babylonjs/materials #babylonjs/loaders #babylonjs/post-processes #babylonjs/procedural-textures #babylonjs/serializers #babylonjs/gui #babylonjs/inspector
webpack.config.js:
const path = require("path");
module.exports = {
entry: './index.ts',
output: {
filename: 'index.js',
path: path.resolve(__dirname, 'dist')
},
resolve: {
extensions: [".ts"]
},
module: {
rules: [
{ test: /\.tsx?$/, loader: "ts-loader" }
]
},
mode: "development",
externals: {
"oimo": true,
"cannon": true,
"earcut": true
},
};
tsconfig.json:
{
"compilerOptions": {
"module": "CommonJS",
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"sourceMap": true,
"moduleResolution": "Node",
"lib": ["ES6","DOM"],
"target": "ES6",
"types": [
"#babylonjs/core",
"#babylonjs/gui",
"#babylonjs/inspector",
"#babylonjs/loaders",
"#babylonjs/materials",
"#babylonjs/post-processes",
"#babylonjs/procedural-textures",
"#babylonjs/serializers"
],
},
"files": [
"./index.ts"
]
}
The imports in my index.ts (vscode shows now errors of missing modules):
import { Engine } from "#babylonjs/core/Engines/engine";
import { Scene } from "#babylonjs/core/scene";
import { Vector3 } from "#babylonjs/core/Maths/math";
import { HemisphericLight } from "#babylonjs/core/Lights/hemisphericLight";
import { Mesh } from "#babylonjs/core/Meshes/mesh";
import { ArcRotateCamera } from "#babylonjs/core/Cameras/arcRotateCamera";
import { MeshBuilder } from "#babylonjs/core/Meshes/meshBuilder";
The packages where installed with npm successfully under node-modules. Also, vscode did recognize them in the index.ts.
So what is wrong here?

Webpack build fails for IE (11)

Trying to setup webpack to build my .js and .vue files.
Seems to no transpile _name() {} style function to regular JavaScript.
Thought it should do that out of the box, straight into commons js unless otherwise specified.
No idea why, it's crashing only in IE with some generic JS syntax error about semi colon out of place.
I guess some little flag, setting, something, somewhere.
Looking for some suggestions here.
ex vue
<script>
export default {
computed: {
_name() {
return 'blah';
}
}
};
</script>
package.json
"#babel/core": "7.0.0-beta.42",
"#babel/plugin-proposal-object-rest-spread": "7.0.0-beta.42",
"#babel/preset-env": "7.0.0-beta.42",
"babel-loader": "8.0.0-beta.2",
"vue-loader": "9.5.1",
"vue-style-loader": "1.0.0",
"sass-loader": "3.2.3",
"node-sass": "^4.1.1",
"css-loader": "0.25.0",
"style-loader": "0.13.1",
"vue-html-loader": "1.2.3",
"file-loader": "^0.8.4",
"webpack": "3.4.1",
"webpack-dev-server": "1.16.1",
"webpack-stream": "3.2.0",
"copy-webpack-plugin": "3.0.1",
"replace-webpack-plugin": "0.1.2",
"uglifyjs-webpack-plugin": "1.2.7"
config
entry: [__dirname + '/../src/bootstrap.js'],
output: {
path: __dirname + '/../public',
filename: 'app.min.js',
chunkFilename: "[name].[chunkhash:4].js",
publicPath: '/',
},
plugins: [
new CopyWebpackPlugin(
(function () {
var copy = [{
to: '',
from: __dirname + '/../src/core/assets'
}, {
to: '',
from: __dirname + '/../src/app/assets'
}];
if (data.copy) {
copy.concat(data.copy);
}
return copy;
})()
),
new ReplacePlugin({
skip: false,
entry: 'src/index.html',
output: '/public/index.html',
hash: '[hash]',
data: {
scripts: data.scripts
}
})
],
module: {
rules: [{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['#babel/preset-env']
}
}
}, {
test: /\.vue$/,
// exclude: /node_modules/,
loader: 'vue-loader',
options: {
loaders: {
js: {
loader: 'babel-loader',
options: {
presets: ['#babel/preset-env']
}
},
sass: 'sass-loader'
}
}
}]
}
build looks like this
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony default export */ __webpack_exports__["default"] = ({
props: ['name', 'timeout', 'max'],
computed: {
_name() {
return this.name || 'global';
},
...
EDIT:
In the end it was just a matter of adding a few specific transform plugins in the .babelrc file at the root. Probably better way to do this via config. Took a while to match the transforms to each error, but the following set worked for me.
{
"plugins": [
"#babel/plugin-transform-spread",
"#babel/plugin-transform-destructuring",
"#babel/plugin-transform-block-scoping",
"#babel/plugin-transform-arrow-functions",
"#babel/plugin-transform-template-literals",
"#babel/plugin-transform-computed-properties",
"#babel/plugin-transform-shorthand-properties"
]
}
Note: each plugin needs to be installed as a dependency also.
Since it is a custom webpack configuration and it is not clear there is any additional configuration to babel, try to add #babel/plugin-transform-shorthand-properties plugin to babel-loader options for .vue files.
loaders: {
js: {
loader: 'babel-loader',
options: {
presets: ['#babel/preset-env'],
plugins: ['#babel/plugin-transform-shorthand-properties']
}
},
sass: 'sass-loader'
}
from the output it is confirmed that shorthand property is not getting transpiled
you are using the shorthand property of ES6 which is not supported on iE you need to configure the babel config so that it transpiled this into older version ( for more info about browser support visit this link)
to make your babel config compatible for ie use something like this in babelrc
{
"presets": [
["env", {
"targets": {
"browsers": ["last 2 versions", "ie >= 11"]
},
"useBuiltIns": true
}],
]
}
if that dosen't work try changing you devtool config in webpack (for example eval to something else ) and check this thread of github

How to use import with absolute paths with Expo and React Native?

I'm trying to use absolute import paths instead of relative paths with Expo and React Native.
I looked on the expo docs and couldn't find an answer... Searching for the subject in react community I found babel-plugin-module-resolver but it seems that Expo is already using it so I've changed my .babelrc to create some aliases:
{
"presets": ["babel-preset-expo"],
"env": {
"development": {
"plugins": [
"transform-react-jsx-source",
["module-resolver", {
"root": ["./app"],
"alias": {
"Components": "./app/components",
}
}]
]
}
}
}
But I got the following error:
Unable to resolve module '#expo/vector-icons/glyphmaps/Entypo.json'
from '/Users/eduardoleal/Code/lua/rook/node_modules/#expo/vector-icons/Entypo.js':
Module does not exist in the module map or in these directories: /Users/eduardoleal/Code/lua/rook/node_modules/#expo/vector-icons/node_modules/#expo/vector-icons/glyphmaps , /Users/eduardoleal/Code/lua/rook/node_modules/#expo/vector-icons/glyphmaps This might be related to https://github.com/facebook/react-native/issues/4968 To resolve try the following:
1. Clear watchman watches: 'watchman watch-del-all'.
2. Delete the 'node_modules' folder: 'rm -rf node_modules && npm install'.
3. Reset packager cache: 'rm -fr $TMPDIR/react-*' or 'npm start --reset-cache'.
ABI16_0_0RCTFatal -[ABI16_0_0RCTBatchedBridge stopLoadingWithError:] __34-[ABI16_0_0RCTBatchedBridge start]_block_invoke_2 _dispatch_call_block_and_release _dispatch_client_callout _dispatch_main_queue_callback_4CF __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ __CFRunLoopRun CFRunLoopRunSpecific GSEventRunModal UIApplicationMain main start 0x0
Is there any easy way to import absolute paths?
Update: Expo v32.0.0 and up
Expo init is creating a babel.config.js for you. Just add the plugins key to your babel.config.js file and add your alias. The env key is not needed anymore.
module.exports = function(api) {
api.cache(true)
return {
presets: ['babel-preset-expo'],
plugins: [
[
'module-resolver',
{
alias: {
assets: './assets',
components: './src/components',
modules: './src/modules',
lib: './src/lib',
types: './src/types',
constants: './src/constants',
},
},
],
],
}
}
Update: Changes for Expo.io SDK v20.0.0
Since SDK v20.0.0 you can use the normal Babel Expo presets
{
"presets": ["babel-preset-expo"],
"env": {
"development": {
"plugins": ["transform-react-jsx-source"]
}
},
"plugins": [
["module-resolver", {
"alias": {
"alias-name": "./app",
}
}]
]
}
Expo.io SDK v19.0.0 and before
Without the root-element, separating plugins and changing presets to babel-preset-react-native-stage-0/decorator-support, an alias work for me.
Using Expo.io on Version 16.0.0
Found this in the Expo Forums here: https://forums.expo.io/t/relative-paths-with-expo/654/3
Can you verify that this works on your case too?
{
"presets": ["babel-preset-react-native-stage-0/decorator-support"],
"env": {
"development": {
"plugins": ["transform-react-jsx-source"]
}
},
"plugins": [
["module-resolver", {
"alias": {
"alias-name": "./app",
}
}]
]
}
For latest expo users(sdk version >= 32).
Just add plugins property in your babel.config.js (find this file in project root directory).
module.exports = function (api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
plugins: [
[
'module-resolver',
{
alias: {
'alias-name': './src/assets/bla/bla',
},
},
],
],
};
};
In adition to Laszlo Schurg's answer in case someone encounters the same problem with Typescript.
If you are using Typescript you also need to add this in your tsconfig
"compilerOptions": {
...
"baseUrl": ".",
"paths": {
"#src/*": ["./src/*"],
"#assets/*": ["./assets/*"]
}
},
That's my config for this babel.config
plugins: [
...
[
"module-resolver",
{
alias: {
"#assets": "./assets",
"#src": "./src",
},
},
],
],
After a while trying to get this working. I could resolve the problem with de following .babelrc:
{
"presets": ["babel-preset-react-native-stage-0/decorator-support"],
"env": {
"development": {
"plugins": ["transform-react-jsx-source"]
}
},
"plugins": [
["module-resolver", {
"alias": {
"react-native-vector-icons": "#expo/vector-icons",
"#expo/vector-icons/lib/create-icon-set": "react-native-vector-icons/lib/create-icon-set",
"#expo/vector-icons/lib/icon-button": "react-native-vector-icons/lib/icon-button",
"#expo/vector-icons/lib/create-icon-set-from-fontello": "react-native-vector-icons/lib/create-icon-set-from-fontello",
"#expo/vector-icons/lib/create-icon-set-from-icomoon": "react-native-vector-icons/lib/create-icon-set-from-icomoon",
"#expo/vector-icons/lib/icon-button": "react-native-vector-icons/lib/icon-button",
"#expo/vector-icons/glyphmaps": "react-native-vector-icons/glyphmaps",
"$components": "./app/components",
"$config": "./app/config",
"$helpers": "./app/helpers",
"$navigators": "./app/navigators",
"$reducers": "./app/reducers",
"$screens": "./app/screens",
"$images": "./assets/images",
"$fonts": "./assets/fonts",
"$icons": "./assets/icons",
"$videos": "./assets/videos",
}
}]
]
}
I copied the content of babel-preset-expo to my .babelrc. It's not the best solution... but it works normally.
More details about it here
./src
|- package.json
|- Bar/
| `- index.js
`- Foo.js
package.json
{
"name": "~" // whatever u want
}
then
import { Foo } from "~/Foo";
import { Bar } from "~/Bar";
// ...
I com with this suggestion:
In your tsconfig.json:
<pre>
<code>
{
"compilerOptions": {
"baseUrl": "./app",
"paths": {
"Components": ["components/*"]
}
},
"include": ["app"]
}
</code>
</pre>
And vite.config.ts resolve might look like this:
<pre>
<code>
resolve: {
alias: {
"Components": "app/components",
}
}
</code>
</pre>
Just simple make you .babelrc simple like this:
{
"presets": ["babel-preset-expo"],
"env": {
"development": {
"plugins": ["transform-react-jsx-source"]
}
}
}
And import like this:
import Entypo from '#expo/vector-icons/Entypo';

Get grunt-stylint to listen to all stylus files

I am trying to get my Gruntfile.js to lint all my stylus files using grunt-stylint, but I am having trouble getting it to listen to all my stylus files, particularly those in subdirectories.
Here is my styles structure:
- assets
- styles
bunch-of-files.styl
- components
even-more-files.styl
I've got it watching all stylus files with this:
watch: {
options: {
livereload: true,
},
pug: {
files: '**/*.pug',
tasks: ['puglint'],
options: {
livereload: true,
},
},
stylus: {
files: '**/*.styl',
tasks: ['stylint','stylus'],
},
scripts :{
files: 'assets/js/*.js',
tasks: ['concat'],
options: {
interrupt: false,
},
},
server: {
files: ['.rebooted'],
options: {
livereload: true
}
}
},
But, the stylint task only looks at the bunch-of-files with this, and not the components/ folder:
stylint: {
options: {
config: '.stylintrc'
},
src: ['**/*.styl']
},
Others I've tried with the same results:
stylint: {
options: {
config: '.stylintrc'
},
src: ['assets/styles/**/*.styl']
},
stylint: {
options: {
config: '.stylintrc'
},
src: ['**/**/*.styl']
},
The only thing that worked was this, but now it only looks in that components/ directory:
stylint: {
options: {
config: '.stylintrc'
},
src: ['assets/styles/*/*.styl']
},
And when I pair that with one of the earlier ones, it only reads the first file. For example this only will read those bunch-of-files.
stylint: {
options: {
config: '.stylintrc'
},
src: ['**/*.styl','assets/styles/*/*.styl']
},
Ideas?
**
editing w full gruntfile + package.json
Gruntfile:
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
stylus: {
build: {
options: {
compress: false,
},
files: {
'public/css/main.css': 'assets/styles/main.styl',
}
}
},
concat: {
options: {
stripBanners: true,
},
basic: {
src: ['assets/js/*.js'],
dest: 'public/js/main.js',
},
},
jshint: {
all: ['Gruntfile.js', 'app.js', 'assets/**/*.js'],
options: {
force: true,
curly: true,
eqeqeq: true,
eqnull: true,
browser: true,
globals: {
jQuery: true
},
},
},
stylint: {
options: {
config: '.stylintrc'
},
src: ['**/*.styl']
},
puglint: {
src: '**/*.pug',
options: {
requireClassLiteralsBeforeAttributes: true,
requireIdLiteralsBeforeAttributes: true,
requireLowerCaseAttributes: true,
requireLowerCaseTags: true,
validateIndentation: 2,
disallowDuplicateAttributes: true,
validateAttributeQuoteMarks: "\""
}
},
watch: {
options: {
livereload: true,
},
pug: {
files: '**/*.pug',
tasks: ['puglint'],
options: {
livereload: true,
},
},
stylus: {
files: '**/*.styl',
tasks: ['stylint','stylus'],
},
scripts :{
files: 'assets/js/*.js',
tasks: ['concat'],
options: {
interrupt: false,
},
},
server: {
files: ['.rebooted'],
options: {
livereload: true
}
}
},
nodemon: {
dev: {
script: 'app.js',
options: {
nodeArgs: ['--debug'],
env: {
PORT: '3000'
},
// omit this property if you aren't serving HTML files and
// don't want to open a browser tab on start
callback: function (nodemon) {
nodemon.on('log', function (event) {
console.log(event.colour);
});
// refreshes browser when server reboots
nodemon.on('restart', function () {
// Delay before server listens on port
setTimeout(function() {
require('fs').writeFileSync('.rebooted', 'rebooted');
}, 1000);
});
}
}
}
},
concurrent: {
target: [['jshint', 'stylint', 'stylus', 'puglint', 'concat', 'watch'],'nodemon' ],
options: {
logConcurrentOutput: true
}
}
});
// Load plugins.
grunt.loadNpmTasks('grunt-contrib-stylus');
grunt.loadNpmTasks('grunt-nodemon');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-concurrent');
grunt.loadNpmTasks('grunt-stylint');
grunt.loadNpmTasks('grunt-puglint');
// Default task(s).
grunt.registerTask('default', ['concurrent']);
};
Package.json
{
"name": "",
"version": "",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"font-awesome-stylus": "^4.5.0",
"grunt": "^0.4.5",
"grunt-cli": "^1.1.0",
"grunt-concurrent": "^2.2.1",
"grunt-contrib-concat": "^1.0.0",
"grunt-contrib-jshint": "^1.0.0",
"grunt-contrib-stylus": "^1.2.0",
"grunt-contrib-watch": "^1.0.0",
"grunt-nodemon": "^0.4.1",
"grunt-puglint": "^1.0.0",
"grunt-stylint": "^0.1.2",
"mustache-express": "^1.2.2",
"open": "0.0.5",
"pug-lint-config-clock": "^1.1.1",
"reload": "^0.7.0",
"stylint": "^1.3.7"
},
"dependencies": {
"express": "^4.13.4",
"pug": "^2.0.0-beta2"
}
}