Book Image

LESS WEB DEVELOPMENT COOKBOOK

Book Image

LESS WEB DEVELOPMENT COOKBOOK

Overview of this book

Table of Contents (19 chapters)
Less Web Development Cookbook
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Importing files with the @import directive


You will know already that the @import directive in CSS can be used to import other CSS files into your CSS code. In Less, you can use the @import directive to import the Less code from other files. The @import directive enables you to spread your Less code over more than one file, which gives you the opportunity to build a logical and easy-to-maintain structure of Less files.

Getting ready

In this recipe, you will create a main project file that will import your other project files. You need to create the following files and directories:

You can edit the Less files with your favorite text editor and use the command-line lessc compiler, as described in the Installing the lessc compiler with npm recipe in Chapter 1, Getting to Grips with the Basics of Less, to compile the project.less file.

How to do it...

  1. Start with editing the project.less file and write the following content into it:

    @import "variables.less";
    @import (reference) "mixins.less";
    @import...