上QQ阅读APP看书,第一时间看更新
How to do it...
- With bash pointed to ~/workspace:, install Surge globally:
npm install --global surge
- Run the surge command.
- A message will appear in your console, asking you to either log in or create an account. You can do either of them straight from the console. When prompted for the project path, just append /app/www to the path provided. The surge command will continue logging a few more things, and in the last logged row, it will write the following message: Success! Project is published and running at vancouver.surge.sh.
- Navigate to the website mentioned in the preceding line (obviously, yours will be different from the one mentioned previously).
- Change your development environment code, then harp compile it (make sure that you are in the worspace/app folder for the compilation to work).
Note that at the time of writing, there is a bug in c9 bash that prevents you from running harp server ./ --port 8080 once you have stopped it to harp compile. However, you can still verify that your Grunt command's compilation of _custom.scss into app/css/bootstrap.css works. To test this, as before, just change the value of the $white variable (from say, gray to yellow). Now, visit the https://<projectname>-<username>.c9users.io/app/ page and live-refresh your browser to see the changes.
- Run the surge command again. It will prompt you for the project path. Just add /app/www to the end of the path and press Enter.
- It will also prompt you for the domain. To avoid having to type the domain name every time you run the surge command, run surge with the following flag:
surge --domain vancouver.surge.sh
- To use a custom domain instead, add a CNAME file (no extensions!) to the root of the www folder:
echo vancouver.surge.sh > CNAME
When running the preceding command, use your own domain or subdomain instead of vancouver.surge.sh.