これ(localhost:3000)を
こう(192.168.10.8:3000)したい。
要するに、スマホからもリアルタイムで動作確認したい。
そのためにいはlocalhostではなくローカルIPでサーバを立ち上げる必要がある。
gulpでは
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
browserSync({ | |
open: 'external', | |
online: true, | |
server: { | |
proxy: '127.0.0.1:3000', | |
baseDir: setting.path.browserSync.dir | |
} | |
}); |
こんな感じでかけるけど、npm scriptのシェルっぽい書き方がわからなかった。
色々調べて以下でOKっぽい。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"scripts": { | |
"build": "npm run clean & npm-run-all -p build:*", | |
"build:css": "postcss src/css/main.pcss -o dist/css/main.css --no-map", | |
"build:js": "mkdirp dist/js && browserify -t babelify src/js/main.js | uglifyjs -c -m > dist/js/main.js", | |
"build:images": "imagemin src/images/* -o dist/images", | |
"clean": "rimraf dist/{css/*,js/*,images/*}", | |
"watch:css": "postcss src/css/main.pcss -o dist/css/main.css -w", | |
"watch:js": "watchify -t babelify src/js/main.js -o 'uglifyjs -c -m > dist/js/main.js' -v", | |
"watch:images": "onchange 'src/images' -e '**/*.DS_Store' -- npm run images", | |
"watch:server": "browser-sync start --open=\"external\" -s -f 'dist, **/*.html, !node_modules/**/*'", | |
"watch": "npm-run-all -p watch:*", | |
"postinstall": "npm run build && npm run watch", | |
"lint:css": "stylelint src/css/**/*.pcss", | |
"lint:js": "eslint src/js/**/*.js" | |
}, |
browser-sync start –open=\”external\”
の様に書く。