Skip to content

Instantly share code, notes, and snippets.

@jacky810124
Created April 22, 2018 15:42
Show Gist options
  • Save jacky810124/d20d42f849518a4920e91e70d9dfdc97 to your computer and use it in GitHub Desktop.
Save jacky810124/d20d42f849518a4920e91e70d9dfdc97 to your computer and use it in GitHub Desktop.
import styles from './styles.scss'
class SomeComponent extends React.Component {
render () {
return (
<div className={styles['some-component']}>
SomeComponent
</div>
)
}
}
export default SomeComponent
const path = require('path')
const webpack = require('webpack')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const config = require('./config')
module.exports = {
entry: {
app: ['babel-polyfill', './src/app.js'],
},
output: {
path: path.resolve('./build'),
filename: '[name]-[hash].js',
publicPath: '/'
},
module: {
rules: [
{
test: /\.css?$/,
use: ExtractTextPlugin.extract({
use: ['css-loader']
})
},
{
test: /\.scss$/,
exclude: [path.resolve('node_modules')],
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: {
modules: true,
sourceMap: true,
localIdentName: '[local]-[hash:base64:5]'
}
},
'postcss-loader',
'sass-loader'
]
})
}
]
},
plugins: [
new ExtractTextPlugin({
filename: process.env.NODE_ENV === 'development'
? 'bundle.css'
: 'bundle-[contenthash:base64:10].css',
disable: process.env.NODE_ENV === 'development',
allChunks: true
})
],
resolve: {
extensions: ['.js', '.json', '.jsx', '.css', '.scss']
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment