SASS integration with webpack.

master
Ben Burlingham 10 years ago
parent bb74b9dfce
commit cf4ff04e40
  1. 3
      index.html
  2. 2
      js/Character.js
  3. 3
      package.json
  4. 5
      sass/character.scss
  5. 15
      webpack.config.js

@ -5,6 +5,7 @@
<title>Document</title> <title>Document</title>
<script src="https://fb.me/react-0.14.7.js"></script> <script src="https://fb.me/react-0.14.7.js"></script>
<script src="https://fb.me/react-dom-0.14.7.js"></script> <script src="https://fb.me/react-dom-0.14.7.js"></script>
<link rel="stylesheet" href="style.css"></link>
<style> <style>
* { * {
@ -13,9 +14,7 @@
} }
.ourhero { .ourhero {
background: aqua;
height:100px; height:100px;
opacity:0.5;
position:absolute; position:absolute;
width:100px; width:100px;
} }

@ -1,6 +1,8 @@
var React = require('react'); var React = require('react');
var Input = require('./Input'); var Input = require('./Input');
require('../sass/character.scss');
var character = React.createClass({ var character = React.createClass({
getInitialState: function() { getInitialState: function() {
return { return {

@ -4,7 +4,7 @@
"description": "MECC's classic Number Munchers game rebuilt with React and Webpack.", "description": "MECC's classic Number Munchers game rebuilt with React and Webpack.",
"main": "./js/main.js", "main": "./js/main.js",
"scripts": { "scripts": {
"start": "./node_modules/webpack-dev-server/bin/webpack-dev-server.js --progress --colors --hot" "start": "./node_modules/webpack-dev-server/bin/webpack-dev-server.js --progress --colors"
}, },
"author": "Ben Burlingham", "author": "Ben Burlingham",
"license": "ISC", "license": "ISC",
@ -15,6 +15,7 @@
"devDependencies": { "devDependencies": {
"css-loader": "^0.23.1", "css-loader": "^0.23.1",
"express": "^4.13.4", "express": "^4.13.4",
"extract-text-webpack-plugin": "^1.0.1",
"jsx-loader": "^0.13.2", "jsx-loader": "^0.13.2",
"node-sass": "^3.4.2", "node-sass": "^3.4.2",
"react": "^0.14.7", "react": "^0.14.7",

@ -1,5 +1,6 @@
.character { .ourhero {
$bg: crimson; $bg: aqua;
background: $bg; background: $bg;
opacity: 0.5;
} }

@ -1,4 +1,6 @@
// http://www.jonathan-petitcolas.com/2015/05/15/howto-setup-webpack-on-es6-react-application-with-sass.html // http://www.jonathan-petitcolas.com/2015/05/15/howto-setup-webpack-on-es6-react-application-with-sass.html
var ExtractTextPlugin = require('extract-text-webpack-plugin');
function getEntrySources() { function getEntrySources() {
var sources = [ var sources = [
'./js/main.js' './js/main.js'
@ -21,6 +23,11 @@ module.exports = {
test: /\.js$/, test: /\.js$/,
include: __dirname + '/js', include: __dirname + '/js',
loaders: ['babel'] loaders: ['babel']
},
{
test: /\.scss$/,
include: __dirname + '/sass',
loader: ExtractTextPlugin.extract('css!sass')
} }
] ]
}, },
@ -28,5 +35,11 @@ module.exports = {
output: { output: {
path: __dirname, path: __dirname,
filename: 'bundle.js' filename: 'bundle.js'
} },
plugins: [
new ExtractTextPlugin('style.css', {
allChunks: true
})
]
}; };

Loading…
Cancel
Save