Npm normalize css gulp

Lotechnica

Prefix normalize.css or sanitize.css before gulp-sass

A pretty common setup for front-end design work is to use Sass to compile .scss files into a single .css file. It’s also pretty common to use a CSS Reset, such as normalize.css or sanitize.css, to reset your CSS to a common base. For that CSS Reset to work, it needs to be included before any of the app-specific CSS, so you can override it and not the other way around. You could just copy the normalize.css file into your project and link it separately in your HTML, or you could even stick it in your scss/ directory and have Sass process it unnecessarily. But what if you want to just install it from npm and have gulp include it in your output app.css file? Here’s a quick and easy way to do that in your gulpfile.js .

This assumes you have a basic gulp setup with:

$ npm install -D gulp gulp-sass gulp-concat 

And assuming you have a gulp.task() like the following:

var gulp = require('gulp'), sass = require('gulp-sass'), concat = require('gulp-concat'); gulp.task('css', function ()  return gulp.src('scss/**/*.scss') .pipe(sass().on('error', sass.logError)) .pipe(concat('app.css')) .pipe(gulp.dest('css/')); >); 

Now you install normalize.css with the following:

$ npm install --save normalize.css 

which will stick it in your node_modules/ subdirectory. How do you tell Gulp to just include that file, then run Sass on your *.scss files, and output it all to css/app.css ? The solution is to create two streams and use the package merge-stream to merge them together before concatenating. So install merge-stream:

$ npm install -D merge-stream 

Then create 2 separate streams, one for the normalize CSS (and any other NPM installed CSS files you might want to use), the other for your Sass processed files. Finally merge them, concatenate, and output. Your gulpfile.js will look like the following:

var gulp = require('gulp'), sass = require('gulp-sass'), concat = require('gulp-concat'), merge = require('merge-stream'); gulp.task('css', function ()  const reset = gulp.src('node_modules/normalize.css/normalize.css'); const scss = gulp.src('scss/**/*.scss') .pipe(sass().on('error', sass.logError)); return merge(reset, scss) .pipe(concat('app.css')) .pipe(gulp.dest('css/')); >); 

Your css/app.css will now contain the contents of normalize.css followed by all of your CSS compiled by Sass. Whenever you update your normalize.css package from NPM, your output will be automatically updated. Unless you pin a specific version of normalize.css which may be a good idea depending on your project.

Источник

Как правильно подключить normalize к gulp?

Как правильно подключить его в GULP’e, чтобы можно его было импортировать через файл libs.sass или main.sass или чтобы он сам автоматически импортировался ??

Сам normalize находится в папке ‘node_modules’, и не очень удобно обращаться к нему через директиву @import.

Оценить 1 комментарий

space2pacman

alvvi

p.s. в gulp-sass оно тоже работает

alvvi

BB 8: нет, просто укажите опцию includePaths: [paths] в вашем gulp-sass/node-sass, где paths — строки с путями к нужным файлам. Пример: includePaths: [‘./node_modules/bootstrap/scss’]
теперь в sass могу написать
@import ‘bootstrap’
и он импортирует мне так же, как если бы я написал

@import '../../node_modules/bootstrap/scss/bootstrap'
Message: app/sass/main.sass Error: File to import not found or unreadable: normalize. Parent style sheet: /home/bb-8/Documents/landing-page-on-flexbox-master/app/sass/main.sass on line 1 of app/sass/main.sass >> @import 'normalize';
gulp.task('sass', function()< // Создаем таск Sass return gulp.src('app/sass/**/*.sass') // Берем источник .pipe(sass().on('error', sass.logError)) // Преобразуем Sass в CSS посредством gulp-sass .pipe(autoprefixer(['last 15 versions', '> 1%', 'ie 8', 'ie 7'], < cascade: true >)) // Создаем префиксы .pipe(gulp.dest('app/css')) // Выгружаем результата в папку app/css .pipe(browserSync.reload()); // Обновляем CSS на странице при изменении >);

в .sass пишу @import ‘normalize’;

alvvi

BB 8: а если пройти по пути ‘./node_modules/normalize.css/’ есть ли там сам normalize.css? В принципе все правильно делаете, но при разрешени импротов ошибки — частое явление. Попробуйте явно указать расширение, при компиляции scss вроде бывают порблемы с этим.

Источник

Npm normalize css gulp

This is simply a renamed normalize.css 8.0.1 file, suitable for importing with npm and libsass directly. No changes have been made to the actual file.

npm install node-normalize-scss --save-dev 
yarn add node-normalize-scss --dev 
var gulp = require("gulp");
var sass = require("gulp-sass");
gulp.task("sass", function()
gulp
.src("path/to/app.scss")
.pipe(
sass(
includePaths: require("node-normalize-scss").includePaths
>)
)
.pipe(gulp.dest("path/to/output.css"));
>);
module.exports =
module:
rules: [
use: [
loader: "sass-loader",
options:
includePaths: require("node-normalize-scss").includePaths
>
>
]
>
]
>
>;

After creating your gulp task, you can import any of the resets like so:

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Sass/SCSS importable normalize.css package (NPM hosted)

License

berstend/normalize.css-importable

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

Due to a Sass bug importing .css files is not working as expected.

This is a fork of normalize.css which only change is to rename the extension to .scss so the package can be imported in .scss files.

Install this package via npm:

npm install normalize.css-importable --save

Mention the path ( ./node_modules/normalize.css-importable/ ) in the includePaths of Sass.

Gulp example (Coffeescript):

gulp.task 'styles', -> sassImports = [ './node_modules/susy/sass/' './node_modules/bourbon/app/assets/stylesheets/' './node_modules/normalize.css-importable/' ] gulp.src paths.glob.styles .pipe $.plumber() .pipe $.sass errLogToConsole: true includePaths: sassImports .pipe gulp.dest paths.dest.assets .pipe $.size title: 'CSS' .pipe reload stream:true

Please make a PR in case normalize.css has been updated.

Normalize.css is a customisable CSS file that makes browsers render all elements more consistently and in line with modern standards.

The project relies on researching the differences between default browser styles in order to precisely target only the styles that need or benefit from normalizing.

  • npm: npm install —save normalize.css
  • Component(1): component install necolas/normalize.css
  • Bower: bower install —save normalize.css
  • cdnjs
  • Download.

No other styles should come before Normalize.css.

It is recommended that you include the normalize.css file as untouched library code.

  • Preserves useful defaults, unlike many CSS resets.
  • Normalizes styles for a wide range of elements.
  • Corrects bugs and common browser inconsistencies.
  • Improves usability with subtle improvements.
  • Explains what code does using detailed comments.
  • Google Chrome (latest)
  • Mozilla Firefox (latest)
  • Mozilla Firefox ESR
  • Opera (latest)
  • Apple Safari 6+
  • Internet Explorer 8+

Normalize.css v1 provides legacy browser support (IE 6+, Safari 4+), but is no longer actively developed.

Additional detail and explanation of the esoteric parts of normalize.css.

The font-family: monospace, monospace hack fixes the inheritance and scaling of font-size for preformated text. The duplication of monospace is intentional. Source.

Normally, using sub or sup affects the line-box height of text in all browsers. Source.

Adding overflow: hidden fixes IE9’s SVG rendering. Earlier versions of IE don’t support SVG, so we can safely use the :not() and :root selectors that modern browsers use in the default UA stylesheets to apply this style. SVG Mailing List discussion

The search input is not fully stylable by default. In Chrome and Safari on OSX/iOS you can’t control font , padding , border , or background . In Chrome and Safari on Windows you can’t control border properly. It will apply border-width but will only show a border color (which cannot be controlled) for the outer 1px of that border. Applying -webkit-appearance: textfield addresses these issues without removing the benefits of search inputs (e.g. showing past searches).

Adding border: 0 corrects an IE 8–11 bug where color (yes, color ) is not inherited by legend .

Please read the CONTRIBUTING.md

Normalize.css is a project by Nicolas Gallagher, co-created with Jonathan Neal.

About

Sass/SCSS importable normalize.css package (NPM hosted)

Источник

Читайте также:  No such object in table java rmi nosuchobjectexception
Оцените статью