I am using webpack and sass-loader to generate a custom.css
file in my public directory. My webpack.config file has the following:
// webpack.config.js
var ExtractTextPlugin = require("extract-text-webpack-plugin");
...
if(process.env.NODE_ENV === 'development'){
var loaders = ['react-hot','babel']
} else {
var loaders = ['babel']
}
module.exports = {
devtool: 'eval',
entry: './app-client.js',
output: {
path: __dirname + '/public/dist',
filename: 'bundle.js',
publicPath: '/dist/'
},
module: {
loaders: [{
test: /\.js$/,
loaders: loaders,
exclude: /node_modules/
},
// Extract SCSS
**{ test: /\.scss$/,
loader: ExtractTextPlugin.extract("style-loader", "css-loader!autoprefixer-loader!sass-loader") },]**,
include: __dirname + '/src/sass'
},
plugins: [
new ExtractTextPlugin("./public/css/style.css", {allChunks: false})
]
};
The css is called in the .views/index.html file:
<link href="/css/custom.css" rel="stylesheet">
The development scripts in my package.json are:
"webpack-dev-server": "NODE_ENV=development PORT=8080 webpack-dev-server --content-base public/ --hot --inline --devtool inline-source-map --history-api-fallback",
"development": "cp views/index.html public/index.html && NODE_ENV=development webpack && npm run webpack-dev-server"
In ./components/App.js
I have:
//stylesheets
import scss from 'custom.scss'
But I get the following error:
RROR in ./components/App.js
Module not found: Error: Cannot resolve module 'custom.scss' in /Users/koko1/apps/bamba-2017/components
@ ./components/App.js 38:18-40