Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
hfpp2012
/
react-spd
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 5ce9631d
authored
May 19, 2017
by
hfpp2012 yinsigan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
add sass loader
1 parent
8ccdf6ba
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
18 additions
and
2 deletions
client/components/App.jsx
client/main.css → client/main.scss
package.json
readme.md
webpack.config.js
yarn.lock
client/components/App.jsx
View file @
5ce9631
import
React
from
'react'
;
import
React
from
'react'
;
import
'../main.css'
;
import
'../main.
s
css'
;
export
default
class
App
extends
React
.
Component
{
export
default
class
App
extends
React
.
Component
{
render
()
{
render
()
{
...
...
client/main.css
→
client/main.
s
css
View file @
5ce9631
.text-center
{
.text-center
{
text-align
:
center
;
text-align
:
center
;
h1
{
padding
:
20px
;
}
}
}
package.json
View file @
5ce9631
...
@@ -21,6 +21,8 @@
...
@@ -21,6 +21,8 @@
"babel-preset-react"
:
"^6.24.1"
,
"babel-preset-react"
:
"^6.24.1"
,
"css-loader"
:
"^0.28.1"
,
"css-loader"
:
"^0.28.1"
,
"extract-text-webpack-plugin"
:
"^2.1.0"
,
"extract-text-webpack-plugin"
:
"^2.1.0"
,
"node-sass"
:
"^4.5.3"
,
"sass-loader"
:
"^6.0.5"
,
"style-loader"
:
"^0.17.0"
"style-loader"
:
"^0.17.0"
}
}
}
}
readme.md
View file @
5ce9631
...
@@ -11,6 +11,8 @@ yarn add html-webpack-plugin
...
@@ -11,6 +11,8 @@ yarn add html-webpack-plugin
yarn add react react-dom
yarn add react react-dom
yarn add --dev sass-loader node-sass
# 产品编译及压缩
# 产品编译及压缩
# https://webpack.js.org/guides/production-build/
# https://webpack.js.org/guides/production-build/
webpack -p
webpack -p
...
...
webpack.config.js
View file @
5ce9631
...
@@ -10,6 +10,15 @@ const HtmlWebpackPluginConfig = new HtmlWebpackPlugin({
...
@@ -10,6 +10,15 @@ const HtmlWebpackPluginConfig = new HtmlWebpackPlugin({
inject
:
'body'
inject
:
'body'
})
})
const
extractSass
=
ExtractTextPlugin
.
extract
({
use
:
[{
loader
:
"css-loader"
},
{
loader
:
"sass-loader"
}],
fallback
:
"style-loader"
})
module
.
exports
=
{
module
.
exports
=
{
entry
:
'./client/index.js'
,
entry
:
'./client/index.js'
,
output
:
{
output
:
{
...
@@ -19,7 +28,7 @@ module.exports = {
...
@@ -19,7 +28,7 @@ module.exports = {
module
:
{
module
:
{
loaders
:
[
loaders
:
[
{
test
:
/
\.(
js|jsx
)
$/
,
loader
:
'babel-loader'
,
exclude
:
/node_modules/
},
{
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
:
[
plugins
:
[
...
...
yarn.lock
View file @
5ce9631
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment