Answer the question
In order to leave comments, you need to log in
How not to prescribe gulp install every time?
Every time I start a project on gulp (a clone from git), I write a line like this in the console:
npm install gulp gulp-jade gulp-sass gulp-csso gulp-imagemin imagemin-pngquant gulp-uglify gulp-concat gulp-connect gulp-open --save-dev Is there any
way to automate this process?
Answer the question
In order to leave comments, you need to log in
Create a standard package.json , throw it into the project folder and run npm install .
More serious automation is required if you create a project more often than at least once a day.
After you write the --save-dev flag, the plugin or plugins in your case are written to the package.json file
like this:
"devDependencies": {
"gulp": "^3.9.0",
"gulp-autoprefixer": "^2.1.0",
}
I wrote a shell script for this, creating a new project looks like this ./install.sh
#!/bin/bash
folder_name=$1 #присваиваем переменной parametr1 значение первого параметра скрипта
# тут нужно указать правильный путь
ROOT='/Applications/MAMP/htdocs/markup.dev'
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m'
echo -e " "
# Создаем папку проекта если ее нет
#
if [ -d "$folder_name" ] ; then
echo -e "${RED}Папка $folder_name существует${NC}\n"
else
mkdir $folder_name
echo -e "${GREEN}Создана папка $folder_name${NC} \n"
fi
# Переходим в папку
#
cd ./$folder_name
# создаем ссылку на папку node_modules, в итоге у нас 1 папка с плагинами и диск не захламляется
ln -s ${ROOT}/clean/node_modules/ ${ROOT}/$folder_name/
mkdir assets dist assets/template assets/scripts assets/images assets/styles assets/fonts
# Копируем файлы
cp -r ${ROOT}/clean/.jshintrc ${ROOT}/$folder_name/.jshintrc
cp -r ${ROOT}/clean/gulpfile.js ${ROOT}/$folder_name/gulpfile.js
cp -r ${ROOT}/clean/package.json ${ROOT}/$folder_name/package.json
cp -r ${ROOT}/clean/assets/template/* ${ROOT}/$folder_name/assets/template/
cp -r ${ROOT}/clean/assets/styles/* ${ROOT}/$folder_name/assets/styles/
cp -r ${ROOT}/clean/assets/scripts/* ${ROOT}/$folder_name/assets/scripts/
echo -e "Проект ${GREEN}$folder_name${NC} успешно создан"
gulp build
gulp
exit 0
There is also yoman , which was invented specifically to automate the creation of basic applications. The only thing is that you have to write a template for the application, but it comes out very flexible.
YO or yoman. it is used in many places and already has many ready-made templates, and in the end you can make your own or correct an existing one. Make a handful of templates for typical projects and go
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question