npm babel-loader babel-core babel-preset-es2015 --save-dev
npm run watch: "webpack --watch --config webpack.config.development.js", npm run build: "webpack -p --config webpack.config.production.js", npm run json : "webpack -- json --profile >stats.json"
choose one
"tasks": {
"browserSync": {
"server": {
"baseDir": "web",
"index": "index.php"
}
"proxy": {"http://webstack.pro.local/webstack.pro/web/",}
},
Yii 2 Basic Project Template is a skeleton Yii 2 application best for rapidly creating small projects.
The template contains the basic features including user login/logout and a contact page. It includes all commonly used configurations that would allow you to focus on adding new features to your application.
assets/ contains assets definition
commands/ contains console commands (controllers)
config/ contains application configurations
controllers/ contains Web controller classes
mail/ contains view files for e-mails
models/ contains model classes
runtime/ contains files generated during runtime
removed tests/ contains various tests for the basic application vendor/ contains dependent 3rd-party packages views/ contains view files for the Web application web/ contains the entry script and Web resources removed license removed requirements removed travis
The minimum requirement by this project template that your Web server supports PHP 5.4.0.
Extract the archive file downloaded from yiiframework.com to
a directory named basic that is directly under the Web root.
Set cookie validation key in config/web.php file to some random secret string:
'request' => [
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
'cookieValidationKey' => '<secret random string goes here>',
],You can then access the application through the following URL:
http://localhost/basic/web/
If you do not have Composer, you may install it by following the instructions at getcomposer.org.
You can then install this project template using the following command:
php composer.phar global require "fxp/composer-asset-plugin:~1.1.1"
php composer.phar create-project --prefer-dist --stability=dev yiisoft/yii2-app-basic basic
Now you should be able to access the application through the following URL, assuming basic is the directory
directly under the Web root.
http://localhost/basic/web/
Edit the file config/db.php with real data, for example:
return [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=yii2basic',
'username' => 'root',
'password' => '1234',
'charset' => 'utf8',
];NOTES:
- Yii won't create the database for you, this has to be done manually before you can access it.
- Check and edit the other files in the
config/directory to customize your application as required. - Refer to the README in the
testsdirectory for information specific to basic application tests.
Gulp Starter is a delicious blend of tasks and build tools poured into Gulp to form a full-featured modern asset pipeline. It can be used as-is as a static site builder, or can be configured and integrated into your own development environment and site or app structure. The extras folder contains configuration details for Rails and Craft, with more to follow. Check out the compiled demo and play with the source files!
git clone https://github.com/vigetlabs/gulp-starter.git MyApp
cd MyApp
npm install
npm start| Features | Tools Used |
|---|---|
| CSS | Sass (Libsass via node-sass), Autoprefixer, CSSNano, Source Maps |
| JavaScript | Babel, Webpack |
| HTML | Nunjucks, gulp-data, or bring your own |
| Images | Compression with imagemin |
| Icons | Auto-generated SVG Sprites and/or Icon Fonts |
| Fonts | Folder and .sass mixin for including WebFonts |
| Live Updating | BrowserSync, Webpack Dev Middleware, Webpack Hot Middleware |
| Production Builds | JS and CSS are uglified and minified, filename md5 hashing (reving), file size reporting, local production Express server for testing builds. |
| JS Testing | Karma, Mocha, Chai, and Sinon, Example Travis CI integration |
| Deployment | Quickly deploy public folder to gh-pages with gulp-gh-pages |
Make sure Node installed. I recommend using NVM to manage versions.
This has been tested on Node 0.12.x - 5.9.0, and should work on newer versions as well. File an issue if it doesn't!
npm installnpm start
Aliases: npm run gulp, npm run development
This is where the magic happens. The perfect front-end workflow. This runs the default gulp task, which starts compiling, watching, and live updating all our files as we change them. BrowserSync will start a server on port 3000, or do whatever you've configured it to do. You'll be able to see live changes in all connected browsers. Don't forget about the additional BrowserSync tools available on port 3001!
Why run this as an npm script? NPM scripts add ./node_modules/bin to the path when run, using the packages version installed with this project, rather than a globally installed ones. Never npm install -g and get into mis-matched version issues again. These scripts are defined in the scripts property of package.json.
npm run test:watchnpm run testnpm run productionBy default, the files in src are pretty minimal. If you're just exploring and would like to play with the demo files, the files available in extras/demo. Just replace src and config.json with the ones in extras/demo, or simply check out the demo branch.
git checkout demo
npm start
If you plan on using this to start a new project, be sure and clear out the git data start a fresh history:
rm -rf .git && git init
git commit -m "Initialized with Gulp Starter"Directory and top level settings are convienently exposed in gulpfile.js/config.json. Use this file to update paths to match the directory structure of your project, and to adjust task options.
All task configuration objects have src and dest directories specfied. These are relative to root.src and root.dest respectively. Each configuration also has an extensions array. This is used for file watching, and file deleting/replacing.
If there is a feature you do not wish to use on your project, simply delete the configuration, and the task will be skipped.
Not all configuration is exposed here. For advanced task configuration, you can always edit the tasks themselves in gulpfile.js/tasks.
npm run gulp
(or npm run development)
This runs gulp from ./node_modules/bin, using the version installed with this project, rather than a globally installed instance. All commands in the package.json scripts work this way. The gulp command runs the default task, defined in gulpfile.js/tasks/default.js.
All files will compile in development mode (uncompressed with source maps). BrowserSync will serve up files to localhost:3000 and will stream live changes to the code and assets to all connected browsers. Don't forget about the additional BrowserSync tools available on localhost:3001!
To run any other existing task, simply add the task name after the gulp command. Example:
npm run gulp productionA README.md with details about each asset task are available in their respective folders in the src directory:
- JavaScript
- Stylesheets
- HTML
- Fonts
- Images
- Icon Font
- SVG Sprite
- Static Files (favicons, app icons, etc.)
npm run production
This will compile revisioned and compressed files to ./public. To build production files and preview them locally, run
npm run demo
This will start a static server that serves your production files to http://localhost:5000. This is primarily meant as a way to preview your production build locally, not necessarily for use as a live production server.
npm run test
Test files located in __tests__ folders are picked up and run using
Karma, Mocha, Chai, and Sinon. The test script right now first compiles a production build, and then, if successful runs Karma. This is nice when using something like Travis CI in that if an error occurs during the build step, Travis alerts me that it failed. To pass, the files have to compile properly AND pass the JS tests.
npm run deploy
This task compiles production code and then uses gulp-gh-pages to push the contents of your dest.root to a gh-pages (or other specified) branch, viewable at http://[your-username].github.io/[your-repo-name]. Be sure to update the homepage property in your package.json.
GitHub Pages isn't the most robust of hosting solutions (you'll eventually run into relative path issues), but it's a great place to quickly share in-progress work, and you get it for free.
Surge.sh might be a good alternative for production-ready static hosting to check out, and is just as easy to deploy to. Where ever you're deploying to, all you need to do is npm run gulp production and transfer the contents of the public folder to your server however you see fit.
For non-static sites (Rails, Craft, etc.), make sure the production task runs as part of your deploy process.
- Full asset pipeline and static html compilation
gulpfile.jsis now a directory- update directory structure
- Replaced Browserify with Webpack!
- Async CommonJS module requires
- Automatically splits out shared dependencies
- New
htmltask w/ Nunjucks templating/compiling - Replace CoffeeScript with ES6 (Babel.js)
- New
servertask to test production files locally - New
deploytask to deploy the public directory to gh-pages - New
revtask that revisions filenames and compress css and js - Use
gulp-watchinstead ofgulp.watch(correctly handles new files) - New
productiontask runs tests, compression + filename revisioning - Remove old examples and extraneous dependencies
- Upgrades dependencies
- Added example Travis CI integration that runs karma tests and production build
- Add SVG sprite implementation from @synapticism in #100
Original Blog Post: https://www.viget.com/articles/gulp-browserify-starter-faq
Visit code.viget.com to see more projects from Viget.


