Update webpack config

This commit is contained in:
LordMathis 2017-07-15 16:58:05 +02:00
parent 7cfb6e330f
commit f0090230b3
2 changed files with 28 additions and 74 deletions

View File

@ -1,47 +0,0 @@
import React, {Component} from 'react';
import jsonfile from 'jsonfile';
export default class Post extends Component {
static blogPost;
constructor() {
super();
var dataPath = path.join(process.cwd(), 'src/helpers/data.json');
jsonfile.readFile(dataPath, function(err, data) {
if (err) throw err;
for (var i = 0; i < data.posts.length; i++) {
var val = data.posts[i];
if (val.filename === this.props.match.params.post) {
blogPost = val;
}
}
}.bind(this));
}
render () {
return (
<div className="content">
<div className="post-header">
<h1>
{blogPost.title}
</h1>
<span>
{blogPost.published}
</span>
{ if (blogPost.updated) {
<span>{ blogPost.updated }</span>
}}
</div>
<div className="post-content" dangerouslySetInnerHTML={{__html: blogPost.body}}>
</div>
</div>
)
}
}

View File

@ -1,19 +1,12 @@
const { resolve, join } = require('path')
const webpack = require('webpack')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const config = {
context: resolve(__dirname, 'src'),
entry: {
bundle: [
'./app-client.js'
],
'vendor/js': [
'react',
'react-dom',
'redux',
'react-redux'
]
},
output: {
@ -32,22 +25,35 @@ const config = {
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
use: [
{
loader: 'css-loader',
options: {
modules: true,
importLoaders: 1,
localIdentName: '[name]_[local]___[hash:base64:5]'
}
},
{
loader: 'postcss-loader'
use: [
'style-loader',
{
loader: 'css-loader',
options: {
modules: true,
importLoaders: 1,
localIdentName: '[name]__[local]___[hash:base64:5]'
}
]
})
}
},
{
loader: 'postcss-loader'
}
]
},
{test: /\.scss$/,
use: [{
loader: "style-loader" // creates style nodes from JS strings
}, {
loader: "css-loader" // translates CSS into CommonJS
}, {
loader: "sass-loader" // compiles Sass to CSS
}]
},
{
test: /\.(png|jpg)$/,
exclude: /node_modules/,
loader: 'url-loader'
},
]
},
plugins: [
@ -57,11 +63,6 @@ const config = {
// this assumes your vendor imports exist in the node_modules directory
return module.context && module.context.indexOf('node_modules') !== -1
}
}),
new ExtractTextPlugin({
filename: '[name].css',
disable: false,
allChunks: true
})
]
}