css文件如何設置scss,Webpack - 如何將scss編譯成單獨的css文件?

2 個答案:

答案 0 :(得分:3)

這是我在嘗試將css編譯成單獨文件時使用的webpack.config.js文件

|-- App

|-- dist

|-- src

|-- css

|-- header.css

|-- sass

|-- img

|-- partials

|-- _variables.scss

|-- main.scss

|--ts

|-- tsconfig.json

|-- user.ts

|-- main.js

|-- app.js

|-- webpack.config.js

var ExtractTextPlugin = require("extract-text-webpack-plugin");

var extractCss = new ExtractTextPlugin("css/style.css");

var autoprefixer = (require("autoprefixer"))({ browsers: ['last 2 versions'] });

var precss = require("precss");

var sugarss = require('sugarss');

var colormin = require('postcss-colormin');

var path = require("path");

module.exports = {

entry: {

app: ['./src/sass/main.scss', './src/main.js']

},

//devtool:"source-map",

output:{

filename: "bundle.js",

path: path.resolve(__dirname,"dist"),

publicPath: "/dist/"

},

resolve: {

extensions: ['', '.webpack.js', '.web.js', '.ts', '.js']

},

module:{

loaders:[

{

test:/\.s?(a|c)ss$/,

exclude: /node_modules/,

loader: ExtractTextPlugin.extract("css!postcss!sass")

},/*

{

test:/\.css$/,

exclude: /node_modules/,

loader: ExtractTextPlugin.extract("style-loader", "css-loader", "postcss-loader","precss")

},*/

{

test: /\.(jpe?g|png|gif|svg)$/i,

loaders: [

'file?hash=sha512&digest=hex&name=[hash].[ext]',

'image-webpack?bypassOnDebug&optimizationLevel=7&interlaced=false'

]

},

{

test: /\.ts$/,

loader: 'ts-loader'

}

]

},

plugins: [

new ExtractTextPlugin("bundle.css")

],

postcss: function(){

return {

plugins: [ autoprefixer, precss ]

}

}

}

答案 1 :(得分:1)

前提條件

CSS-裝載機

節點SASS

SASS裝載機

式裝載機

提取物的文本的WebPack-插件

$ npm install css-loader node-sass sass-loader style-loader extract-text-webpack-plugin --save-dev

webpack.config.js

這是我的演示webpack.config.js,根據您的項目結構更改路徑:

const ExtractTextPlugin = require('extract-text-webpack-plugin');

const path = require('path');

const srcPath = path.join(__dirname, 'src');

const dstPath = path.join(__dirname, 'dst');

const sassLoaders = [

'css-loader?minimize',

'sass-loader?indentedSyntax=sass&includePaths[]=' + srcPath

];

module.exports = {

entry: {

client: './src/js/client'

},

module: {

loaders: [

/*README:https://github.com/babel/babel-loader*/

{

test: /\.(js|jsx)$/,

exclude: /(node_modules|bower_components)/,

loader: 'babel',

query: {

presets: ['react', 'es2015'],

cacheDirectory: true

},

plugins: ['transform-runtime']

},

{

test: /\.scss$/,

loader: ExtractTextPlugin.extract('style-loader', sassLoaders.join('!'))

},

{

test: /\.(png|jpg|bmp)$/,

loader: 'url-loader?limit=8192'

}

]

},

output: {

path: dstPath,

filename: '[name].js'

},

plugins: [

new ExtractTextPlugin('[name].min.css')

]

};

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/388346.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/388346.shtml
英文地址,請注明出處:http://en.pswp.cn/news/388346.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Iphone表視圖的簡單操作

1.創建一個Navigation—based—Application項目,這樣Interface Builder中會自動生成一個Table View,然后將Search Bar拖放到表示圖上,以我們要給表示圖添加搜索功能,不要忘記將Search Bar的delegate連接到File‘s Owner項&#xf…

PhantomJS的使用

PhantomJS安裝下載地址 配置環境變量 成功! 轉載于:https://www.cnblogs.com/hankleo/p/9736323.html

aws emr 大數據分析_DataOps —使用AWS Lambda和Amazon EMR的全自動,低成本數據管道

aws emr 大數據分析Progression is continuous. Taking a flashback journey through my 25 years career in information technology, I have experienced several phases of progression and adaptation.進步是連續的。 在我25年的信息技術職業生涯中經歷了一次閃回之旅&…

21eval 函數

eval() 函數十分強大 ---- 將字符串 當成 有效的表達式 來求職 并 返回計算結果 1 # 基本的數學計算2 print(eval("1 1")) # 23 4 # 字符串重復5 print(eval("* * 5")) # *****6 7 # 將字符串轉換成列表8 print(eval("[1, 2, 3, 4]")) # [1,…

聯想r630服務器開啟虛擬化,整合虛擬化 聯想萬全R630服務器上市

虛擬化技術的突飛猛進,對運行虛擬化應用的服務器平臺的運算性能提出了更高的要求。近日,聯想萬全R630G7正式對外發布。這款計算性能強勁,IO吞吐能力強大的四路四核服務器,主要面向高端企業級應用而開發。不僅能夠完美承載大規模數…

Iphone屏幕旋轉

該示例是想在手機屏幕方向發生改變時重新定位視圖(這里是一個button) 1.創建一個View—based Application項目,并在View窗口中添加一個Round Rect Button視圖,通過尺寸檢查器設置其位置,然后單擊View窗口右上角的箭頭圖標來旋轉窗…

先進的NumPy數據科學

We will be covering some of the advanced concepts of NumPy specifically functions and methods required to work on a realtime dataset. Concepts covered here are more than enough to start your journey with data.我們將介紹NumPy的一些高級概念,特別是…

lsof命令詳解

基礎命令學習目錄首頁 原文鏈接:https://www.cnblogs.com/ggjucheng/archive/2012/01/08/2316599.html 簡介 lsof(list open files)是一個列出當前系統打開文件的工具。在linux環境下,任何事物都以文件的形式存在,通過文件不僅僅可以訪問常規…

Xcode中捕獲iphone/ipad/ipod手機攝像頭的實時視頻數據

目的:打開、關閉前置攝像頭,繪制圖像,并獲取攝像頭的二進制數據。 需要的庫 AVFoundation.framework 、CoreVideo.framework 、CoreMedia.framework 、QuartzCore.framework 該攝像頭捕抓必須編譯真機的版本,模擬器下編譯不了。 函…

統計和冰淇淋

Photo by Irene Kredenets on UnsplashIrene Kredenets在Unsplash上拍攝的照片 摘要 (Summary) In this article, you will learn a little bit about probability calculations in R Studio. As it is a Statistical language, R comes with many tests already built in it, …

信息流服務器哪種好,選購存儲服務器需要注意六大關鍵因素,你知道幾個?

原標題:選購存儲服務器需要注意六大關鍵因素,你知道幾個?信息技術的飛速發展帶動了整個信息產業的發展。越來越多的電子商務平臺和虛擬化環境出現在企業的日常應用中。存儲服務器作為企業建設環境的核心設備,在整個信息流中承擔著…

t3 深入Tornado

3.1 Application settings 前面的學習中,在創建tornado.web.Application的對象時,傳入了第一個參數——路由映射列表。實際上Application類的構造函數還接收很多關于tornado web應用的配置參數。 參數: debug,設置tornado是否工作…

vml編輯器

<HTML xmlns:v> <HEAD> <META http-equiv"Content-Type" content"text/html; Charsetgb2312"> <META name"GENERATOR" content"網絡程序員伴侶(Lshdic)2004"> <META name"GENERATORDOWNLOADADDRESS&q…

對數據倉庫進行數據建模_確定是否可以對您的數據進行建模

對數據倉庫進行數據建模Some data sets are just not meant to have the geospatial representation that can be clustered. There is great variance in your features, and theoretically great features as well. But, it doesn’t mean is statistically separable.某些數…

15 并發編程-(IO模型)

一、IO模型介紹 1、阻塞與非阻塞指的是程序的兩種運行狀態 阻塞&#xff1a;遇到IO就發生阻塞&#xff0c;程序一旦遇到阻塞操作就會停在原地&#xff0c;并且立刻釋放CPU資源 非阻塞&#xff08;就緒態或運行態&#xff09;&#xff1a;沒有遇到IO操作&#xff0c;或者通過某種…

arduino消息服務器,在C(Arduino IDE)中將API鏈接消息解析為服務器(示例代碼)

我正在使用Arduino IDE來編程我的微控制器&#xff0c;它有一個內置的Wi-Fi芯片(ESP8266 NodeMCU)&#xff0c;它連接到我的互聯網路由器&#xff0c;然后有一個特定的IP(就像192.168.1.5)。所以我想通過添加到鏈接的消息發送命令(和數據)&#xff0c;然后鏈接變為&#xff1a;…

不提拔你,就是因為你只想把工作做好

2019獨角獸企業重金招聘Python工程師標準>>> 我有個朋友&#xff0c;他30出頭&#xff0c;在500強公司做技術經理。他戴無邊眼鏡&#xff0c;穿一身土黃色的夾克&#xff0c;下面是一條常年不洗的牛仔褲加休閑皮鞋&#xff0c;典型技術高手范。 三 年前&#xff0c;…

python內置函數多少個_每個數據科學家都應該知道的10個Python內置函數

python內置函數多少個Python is the number one choice of programming language for many data scientists and analysts. One of the reasons of this choice is that python is relatively easier to learn and use. More importantly, there is a wide variety of third pa…

C#使用TCP/IP與ModBus進行通訊

C#使用TCP/IP與ModBus進行通訊1. ModBus的 Client/Server模型 2. 數據包格式及MBAP header (MODBUS Application Protocol header) 3. 大小端轉換 4. 事務標識和緩沖清理 5. 示例代碼 0. MODBUS MESSAGING ON TCP/IP IMPLEMENTATION GUIDE 下載地址&#xff1a;http://www.modb…

Hadoop HDFS常用命令

1、查看hdfs文件目錄 hadoop fs -ls / 2、上傳文件 hadoop fs -put 文件路徑 目標路徑 在瀏覽器查看:namenodeIP:50070 3、下載文件 hadoop fs -get 文件路徑 保存路徑 4、設置副本數量 -setrep 轉載于:https://www.cnblogs.com/chaofan-/p/9742633.html