How to pack and separate SASS

This article mainly introduces how to pack and separate SASS, the introduction is very detailed, with a certain reference value, interested friends must have read!

package.json is the package management profile in npm, webpack.config.js is the default configuration file of WebPack, WebPack.plugin.js is what I look clearer in order to make WebPack.config.js Some configuration contents extracted, as the name refer to extract the configuration of the plugin.

Node_Modules is the installation directory that executes the rear packet after npm install.

Package and separated the Sass

Install two packages in the project directory:

npm install -save-dev node-surl

npm install -save -dev Sass-loader

If the installation is unsuccessful, you need to delete the node_modules directory. After re-npm install installed the directory, install these two packages again

Write the loader configuration:

 Loader's configuration has a presence order {Test: /\.scss $/, use: [{loader: "style-loader" // creates style nodes from js strings}, {loader: " Css-loader "// translates css into commonjs}, {loader:" Sass-loader "// compiles Sass to CSS}]} Src / Index.html Insert a layer of blocks in Sass  
Sass Documentation: in SRC / CSSInside new Sassle.SCSS file $ NAV-color: #fff; #Sasslearn {$ Width: 100%; Width: $ width; height: 30px; Background-Color: $ NAV-Color;}
Inside the SRC / Entry.js introduced Sassimport Sass from ‘./css/sassle.scss’WebPack NPM Run Server View the effect (but at this time #sasslearn is packaged to entry.js) Moinee ({Use: [{loader: ‘css-loader’}, {loadinger: ‘Sass-loader’}], Fallback: ‘Style- Loader ‘}
  Delete the Dist folder WebPack for packaging, view the style settings of #sasslearn in dist / css / index.css (ie, separated the Sass and JS files)  
How to pack and separate the contents of Sass, thank you for reading! The content that wants to share is helpful to everyone, more related knowledge, welcome to pay attention to Tumi Yun Industry News Channel!

© Copyright Notice
Just support it if you like
comment Grab the couch

Please log in to comment