Adding SCSS variables config to webpack prod config

This commit is contained in:
Adolfo Panizo 2018-03-05 11:02:45 +01:00
parent 90b1c4fe04
commit 7df9ec1bc8
12 changed files with 20 additions and 15 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
node_modules/
build/
build_webpack/
build/contracts/
truffle-config.js

View File

@ -113,6 +113,7 @@ module.exports = {
/\.html$/,
/\.(js|jsx)$/,
/\.css$/,
/\.scss$/,
/\.json$/,
/\.woff$/,
/\.woff2$/,
@ -138,8 +139,8 @@ module.exports = {
}
},
{
test: /\.css$/,
loader: 'style!css?importLoaders=1&modules=true&minimize=true&localIdentName=[name]__[local]___[hash:base64:5]!postcss?sourceMap'
test: /\.(scss|css)$/,
loader: 'style!css?importLoaders=1&modules=true&minimize=false&localIdentName=[name]__[local]___[hash:base64:5]!postcss?sourceMap'
},
// "postcss" loader applies autoprefixer to our CSS.
// "css" loader resolves paths in CSS and adds assets as dependencies.

View File

@ -1,4 +1,5 @@
var autoprefixer = require('autoprefixer');
var cssvars = require('postcss-simple-vars');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
@ -8,7 +9,7 @@ var url = require('url');
var paths = require('./paths');
var getClientEnvironment = require('./env');
var cssvariables = require(paths.appSrc + '/theme/variables');
function ensureSlash(path, needsSlash) {
var hasSlash = path.endsWith('/');
@ -116,6 +117,7 @@ module.exports = {
/\.html$/,
/\.(js|jsx)$/,
/\.css$/,
/\.scss$/,
/\.json$/,
/\.woff$/,
/\.woff2$/,
@ -146,8 +148,8 @@ module.exports = {
// use the "style" loader inside the async code so CSS from them won't be
// in the main CSS file.
{
test: /\.css$/,
loader: ExtractTextPlugin.extract('style', 'css?importLoaders=1!postcss')
test: /\.(scss|css)$/,
loader: ExtractTextPlugin.extract('style', 'css?importLoaders=1&modules=true&minimize=false!postcss?sourceMap')
// Note: this won't work without `new ExtractTextPlugin()` in `plugins`.
},
// JSON is not enabled by default in Webpack but both Node and Browserify
@ -200,6 +202,12 @@ module.exports = {
'not ie < 9', // React doesn't support IE8 anyway
]
}),
cssvars({
variables: function () {
return Object.assign({}, cssvariables);
},
silent: true
}),
];
},
plugins: [

View File

@ -7,7 +7,7 @@ import contract from 'truffle-contract'
import TextField from './components/forms/TextField'
import Page from './components/layout/Page'
import PageFrame from './components/layout/PageFrame'
import './App.css'
import './App.scss'
class App extends Component {
constructor(props) {

View File

@ -1,6 +1,6 @@
body {
font-family: 'Montserrat', sans-serif;
color: $(secondary);
color: $secondary;
background-color: #f0f1f3;
}

View File

@ -1,5 +1,5 @@
import React from 'react'
import styles from './index.css';
import styles from './index.scss';
const Header = () => (
<header className={styles.header}>

View File

@ -1,6 +1,6 @@
import React from 'react'
import Header from '../../Header'
import styles from './index.css';
import styles from './index.scss';
const Page = ({children}) => (
<div className={styles.page}>

View File

@ -1,5 +1,5 @@
import React from 'react'
import styles from './index.css';
import styles from './index.scss';
const PageFrame = ({ children }) => (
<main className={styles.container}>

View File

@ -1,5 +0,0 @@
body {
margin: 0;
padding: 0;
font-family: sans-serif;
}