json comile sass to css with autoprefixer and webpack
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了json comile sass to css with autoprefixer and webpack相关的知识,希望对你有一定的参考价值。
"use strict"
const path = require("path");
const webpack = require("webpack");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const autoprefixer = require("autoprefixer");
module.exports = {
entry: {
sample: path.join(__dirname, "src/css/sample.sass"),
},
output: {
path: path.join(__dirname, "public/css"),
filename: "[name].css"
},
module: {
rules: [
{
test: /\.s[ac]ss$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: [
"css-loader",
{loader: 'postcss-loader', options: { plugins: [autoprefixer({browsers: [">= 0.1%"]})]}},
"sass-loader"
]
})
}
]
},
plugins: [
new ExtractTextPlugin({ filename: '[name].css', disable: false, allChunks: true })
]
};
@charset "UTF-8"
$darkblue: #00008B
.sample
color: $darkblue
font-size: large
display: flex
background-image: linear-gradient(left, red, orange, yellow, green, blue, indigo, violet)
user-select: none
.sample {
color: #00008B;
font-size: large;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
background-image: -webkit-linear-gradient(left, red, orange, yellow, green, blue, indigo, violet);
background-image: linear-gradient(left, red, orange, yellow, green, blue, indigo, violet);
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none; }
{
"name": "sass-autoprefixer-sample",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build-css": "rm -rf public && webpack --debug --config webpack.config.js"
},
"author": "",
"license": "ISC",
"devDependencies": {
"autoprefixer": "^7.1.5",
"css-loader": "^0.28.7",
"extract-text-webpack-plugin": "^3.0.1",
"node-sass": "^4.5.3",
"postcss-loader": "^2.0.8",
"sass-loader": "^6.0.6",
"style-loader": "^0.19.0",
"webpack": "^3.8.1"
}
}
以上是关于json comile sass to css with autoprefixer and webpack的主要内容,如果未能解决你的问题,请参考以下文章
SASS初体验
强制 sass-loader 修改 css 文件
React 中使用sass
sass
1-8 Sass的基本特性-运算
在 Visual Studio Code 中使用 tasks.json 转换 typescript 和 sass