Commit 5ce9631d by hfpp2012 yinsigan

add sass loader

1 parent 8ccdf6ba
import React from 'react';
import '../main.css';
import '../main.scss';
export default class App extends React.Component {
render() {
......
.text-center {
text-align: center;
h1 {
padding: 20px;
}
}
......@@ -21,6 +21,8 @@
"babel-preset-react": "^6.24.1",
"css-loader": "^0.28.1",
"extract-text-webpack-plugin": "^2.1.0",
"node-sass": "^4.5.3",
"sass-loader": "^6.0.5",
"style-loader": "^0.17.0"
}
}
......@@ -11,6 +11,8 @@ yarn add html-webpack-plugin
yarn add react react-dom
yarn add --dev sass-loader node-sass
# 产品编译及压缩
# https://webpack.js.org/guides/production-build/
webpack -p
......
......@@ -10,6 +10,15 @@ const HtmlWebpackPluginConfig = new HtmlWebpackPlugin({
inject: 'body'
})
const extractSass = ExtractTextPlugin.extract({
use: [{
loader: "css-loader"
}, {
loader: "sass-loader"
}],
fallback: "style-loader"
})
module.exports = {
entry: './client/index.js',
output: {
......@@ -19,7 +28,7 @@ module.exports = {
module: {
loaders: [
{ test: /\.(js|jsx)$/, loader: 'babel-loader', exclude: /node_modules/ },
{ test: /\.css$/, loader: ExtractTextPlugin.extract({ fallback: "style-loader", use: "css-loader" }), exclude: /node_modules/ }
{ test: /\.scss/, loader: extractSass, exclude: /node_modules/ }
]
},
plugins: [
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!