npm-build-boilerplate开源项目

我要开发同款
匿名用户2021年11月17日
43阅读
开发技术JavaScript
所属分类应用工具、终端/远程登录
授权协议Readme

作品详情

npm-build-boilerplate

Acollectionofpackagesthatbuildawebsiteusingnpmscripts.

ListofpackagesusedUsinginyourprojectListofavailabletasksNeedhelp?Listofpackagesused

autoprefixer,browser-sync,eslint,imagemin-cli,node-sass,onchange,npm-run-all,postcss-cli,svgo,svg-sprite-generator,uglify-js.

Many,manythanksgoouttoKeithCirkelforhispostandhisusefulCLItools!

UsinginyourprojectFirst,ensurethatnode.js&npmarebothinstalled.Ifnot,chooseyourOSandinstallationmethodfromthispageandfollowtheinstructions.Next,useyourcommandlinetoenteryourprojectdirectory.Ifthisanewproject(withoutapackage.jsonfile),startbyrunningnpminit.Thiswillaskafewquestionsanduseyourresponsestobuildabasicpackage.jsonfile.Next,copythe"devDependencies"objectintoyourpackage.json.Ifthisisanexistingproject,copythecontentsof"devDependencies"intoyourpackage.json.Now,copyanytasksyouwantfromthe"scripts"objectintoyourpackage.json"scripts"object.Finally,runnpminstalltoinstallallofthedependenciesintoyourproject.

You'rereadytogo!Runanytaskbytypingnpmruntask(where"task"isthenameofthetaskinthe"scripts"object).Themostusefultaskforrapiddevelopmentiswatch.Itwillstartanewserver,openupabrowserandwatchforanySCSSorJSchangesinthesrcdirectory;onceitcompilesthosechanges,thebrowserwillautomaticallyinjectthechangedfile(s)!

Listofavailabletasksclean

rm-fdist/{css/*,js/*,images/*}

Deleteexistingdistfiles

autoprefixer

postcss-uautoprefixer-rdist/css/*

AddvendorprefixestoyourCSSautomatically

scss

node-sass--output-stylecompressed-odist/csssrc/scss

CompileScsstoCSS

lint

eslintsrc/js

"Lint"yourJavaScripttoenforceauniformstyleandfinderrors

uglify

mkdir-pdist/js&&uglifyjssrc/js/*.js-m-odist/js/app.js&&uglifyjssrc/js/*.js-m-c-odist/js/app.min.js

Uglify(minify)aproductionreadybundleofJavaScript

imagemin

imageminsrc/images/*-odist/images

Compressalltypesofimages

icons

svgo-fsrc/images/icons&&mkdir-pdist/images&&svg-sprite-generate-dsrc/images/icons-odist/images/icons.svg

CompressseparateSVGfilesandcombinethemintooneSVG"sprite"

serve

browser-syncstart--server--files'dist/css/*.css,dist/js/*.js,**/*.html,!node_modules/**/*.html'

StartanewserverandwatchforCSS&JSfilechangesinthedistfolder

build:css

run-sscssautoprefixer

Aliastorunthescssandautoprefixertasks.CompilesScsstoCSS&addvendorprefixes

build:js

run-slintconcatuglify

Aliastorunthelint,concatanduglifytasks.LintsJS,combinessrcJSfiles&uglifiestheoutput

build:images

run-simageminicons

Aliastoruntheimageminandiconstasks.Compressesimages,generatesanSVGspritefromafolderofseparateSVGs

build

run-sbuild:*

Aliastorunallofthebuildcommands

watch:css

onchange'src/**/*.scss'--run-sbuild:css

Watchesforany.scssfileinsrctochange,thenrunsthebuild:csstask

watch:js

onchange'src/**/*.js'--run-sbuild:js

Watchesforany.jsfileinsrctochange,thenrunsthebuild:jstask

watch:images

onchange'src/images/**/*'--run-sbuild:images

Watchesforanyimagesinsrctochange,thenrunsthebuild:imagestask

watch

run-pservewatch:*

Runthefollowingtaskssimultaneously:serve,watch:css,watch:js&watch:images.Whena.scssor.jsfilechangesinsrcoranimagechangesinsrc/images,thetaskwillcompilethechangestodist,andtheserverwillbenotifiedofthechange.Anybrowserconnectedtotheserverwilltheninjectthenewfilefromdist

postinstall

run-sbuildwatch

Runswatchafternpminstallisfinished

Needhelp?

Feelfreetocreateanissue,tweetme,orsendmeanemail.I'dbegladtohelpwhereIcan!

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论