Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS not applying #40

Open
attiqeurrehman opened this issue Apr 4, 2017 · 5 comments
Open

CSS not applying #40

attiqeurrehman opened this issue Apr 4, 2017 · 5 comments

Comments

@attiqeurrehman
Copy link

Hi,

I have changed the App.scss and it's appending in to the style.css. Please see the screenshot below:

1

2

But for some reason it's not been applied to the site. Any ideas?

@pauldotknopf
Copy link
Owner

What does your styles.css look like?

Also, your generated html markup?

@attiqeurrehman
Copy link
Author

Please find the attached generated style.css and generated html markup. https://drive.google.com/open?id=0BxaNpya8aCYvOXRJeFZqUkFxWWc

@meninjanho4788
Copy link

meninjanho4788 commented Apr 5, 2017

@attiqeurrehman your file App.scss should :
:global {
.classA{
background-color:red;
}
}

if you upgrade to webpack 2.0, no need :global in scss file.
import './App.scss';

@attiqeurrehman
Copy link
Author

I have fixed this by changing the dev.config.js using this:

From

{ test: /\.css$/, loader: 'css/locals?module' },
{ test: /\.scss$/, loader: 'css/locals?module!sass' },

To

 { test: /\.css$/, loader: 'css' },
 { test: /\.scss$/, loader: 'css!sass' },

and from

{ test: /\.css$/, loader: extractCSS.extract('style', 'css?modules') },
{ test: /\.scss$/, loader: extractCSS.extract('style', 'css?modules!sass') },

to

{ test: /\.css$/, loader: extractCSS.extract('style', 'css') },
{ test: /\.scss$/, loader: extractCSS.extract('style', 'css!sass') },

No idea why it worked.

@meninjanho4788
Copy link

My webpack 2.0
var fs = require('fs');
var babelrc = JSON.parse(fs.readFileSync('./.babelrc'));
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var extractCSS = new ExtractTextPlugin('styles.css');
var webpack = require('webpack');
var path = require('path');

module.exports = {
server: {
entry: {
server: [
path.resolve(__dirname, '..', '..', 'Scripts', 'server.js')
]
},
resolve: {
modules: [
"Scripts",
"node_modules"
],
alias: {
'superagent': path.resolve(__dirname, '..', 'utils', 'superagent-server.js'),
'promise-window': path.resolve(__dirname, '..', 'utils', 'promise-window-server.js')
}
},
module: {
loaders: [
{ test: /.(js|jsx)$/, exclude: /node_modules/, use: ["babel-loader?" + JSON.stringify(babelrc), "eslint-loader", ], },
{ test: /.css/, loaders: ['css-loader'] },
{ test: /.scss$/, loaders: ['raw-loader', 'sass-loader?sourceMap'] },
{ test: /.(woff2?|ttf|eot|svg)$/, loader: 'url-loader?limit=10000' },
{ test: /.(jpg|png|gif)$/, loader: 'file-loader' }
]
},
output: {
filename: '[name].generated.js',
libraryTarget: 'this',
path: path.resolve(__dirname, '..', '..', 'wwwroot', 'pack'),
publicPath: '/pack/'
},
plugins: [
new webpack.DefinePlugin({
CLIENT: false,
SERVER: true
})
],
},
client: {
entry: {
client: [
path.resolve(__dirname, '..', '..', 'Scripts', 'client.js')
]
},
resolve: {
modules: [
"Scripts",
"node_modules"
]
},
module: {
loaders: [
{ test: /.(js|jsx)$/, exclude: /node_modules/, use: ["babel-loader?" + JSON.stringify(babelrc), "eslint-loader", ], },
{
test: /.css$/,
use: extractCSS.extract(['css-loader'])
},
{
test: /.scss$/,
use: extractCSS.extract({
fallback: 'style-loader',
use: ['css-loader', 'sass-loader']
})
},
{ test: /.(woff2?|ttf|eot|svg)$/, loader: 'url-loader?limit=10000' },
{ test: /.(jpg|png|gif)$/, loader: 'file-loader' }
]
},
output: {
filename: '[name].generated.js',
libraryTarget: 'this',
path: path.resolve(__dirname, '..', '..', 'wwwroot', 'pack'),
publicPath: '/pack/'
},
plugins: [
extractCSS,
new webpack.DefinePlugin({
CLIENT: true,
SERVER: false
})
],
devtool: 'source-map'
}
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants