在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):arillo/gulp-plate开源软件地址(OpenSource Url):https://github.com/arillo/gulp-plate开源编程语言(OpenSource Language):CSS 72.8%开源软件介绍(OpenSource Introduction):Gulp-plateGulp boilerplate & build system. Includes the following tools, tasks, and work-flows:
Looking for the SilverStripe version? Look here. Dependencies / InstallationGulp-plate depends on the following technologies:
[1] It is recommended to install node trough nvm (Node Version Manager). To get started: $ git clone https://github.com/arillo/gulp-plate myProject
$ cd myProject
$ rm -r .git # Remove the link to the git repo
$ yarn # Install dependencies Commands# Equivalent
$ yarn run build Run the default task and generate a dev version of the site in the # Equivalent
$ yarn start
$ yarn run watch Run the default task once, start a server and watch for file changes. # Equivalent
$ yarn run prod Set If you want to run any other gulp task just append the task name to the build /gulp command: # Equivalent
$ yarn run build sprite
$ yarn run b sprite
$ yarn run gulp sprite
$ yarn run g sprite Important: The Folder structuremyProject/
gulpfile.js/ # gulp tasks
src/
icons/ # SVG files to be included in he the sprite
images/ # other images
js/ # js code
sass/ # Sass code, SCSS and Sass indented syntax possible
html/ # html templates
data/ # data in json format
layouts/ # reusable layout templates
macros/ # Nunjucks macros
shared/ # reusable snippets ConfigurationAll paths and plugin settings have been abstracted into a centralized file: SVG Sprite configurationThe sprite creates an image with the name The generated Sass files contains useful information about the sprite icons like the dimensions of each icon. The file will change every time an icon is added, removed or changed, do not edit it manually. You can change the file by changing the template in Static assetsTo move static assets from the source directory without transformations, e.g. font files. Add the HTML TemplatesTemplates use Nunjucks. See the docs for more information on how to use them. SassSass indented syntax is used by default. The main Sass files need to have a Include external vendor css filesTo include third-party styles in your css use include them in the // main.sass
@import url('../../node_modules/normalize.css/normalize.css'); A postcss plugin will then inline the files preserving the source-maps. After the Sass compilation. Beware that Sass will move Sass-lint errorsAt the time of writing .mySelector
//
.mySelector_child
text-align: center JavaScriptThe There configuration will be slightly altered depending on the task you are running. When using the watch task, Javascript compilation will happen in memory, so no files are written to disk ( Here are some useful recipes to get you up and running: Declare aliases for frequently required files// gulpfile.js/config.js
const js = {
resolve: {
extensions: ['.js'],
alias: {
// Path relative to `context`
myModule: './myModule/myModule.js',
},
},
}; // src/js/some-file.js
import myModule from 'myModule';
myModule(); Docs: https://webpack.js.org/configuration/resolve/#resolve-alias Shimming non CommonJs modulesjQuery plugin// gulpfile.js/config.js
const webpack = require('webpack');
//...
const js = {
plugins: [
// Make jQuery global, expected by the plugin.
new webpack.ProvidePlugin({
'window.jQuery': 'jquery',
}),
],
//...
resolve: {
// Add extensions to prevent linting errors.
extensions: ['.js', '.json'],
// Path from `node_modules`, where `myModule` is the module name.
alias: {
myModule: 'myModule/dist/myModule.js',
},
},
}; // src/js/main.js
import $ from 'jquery';
import 'myModule';
$('.js-selector').myModule(); Regular JavaScript module// gulpfile.js/config.js
const js = {
//...
resolve: {
// Add extensions to prevent linting errors.
extensions: ['.js', '.json'],
// Path from `node_modules`, where `myModule` is the module name.
alias: {
myModule: 'myModule/dist/myModule.js',
},
},
module: {
rules: [
// ...
{
include: require.resolve('myModule/dist/myModule.js'),
loader: 'exports-loader?MyModule',
},
],
},
}; // src/js/main.js
import $ from 'jquery';
import MyModule from 'myModule';
const myInstance = new MyModule(); Docs: https://webpack.js.org/guides/shimming/ Multiple JavaScript bundles & vendor code sharingTo create multiple bundles add entires to // gulpfile.js/config.js
const js = {
// ...
entry: {
main: ['./main.js'],
other: ['./someFile.js', './sotherOtherFile.js'],
},
// ...
}; This will generate two bundles: If you do this it is probably a good idea to generate another bundle that contains all shared vendor code: // gulpfile.js/config.js
const webpack = require('webpack');
//...
const js = {
// ...
entry: {
main: ['./main.js'],
other: ['./someFile.js', './sotherOtherFile.js'],
// List vendor modules here:
vendor: ['jquery', 'svg4everybody'],
},
// ...
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor', // Specify the common bundle's name
}),
],
// ...
}; Docs: https://webpack.js.org/guides/code-splitting-libraries/ Roadmap
CreditsGulp-plate is based on https://github.com/greypants/gulp-starter |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论