From f0090230b307c5f84761c817c36fe359c514d589 Mon Sep 17 00:00:00 2001 From: LordMathis Date: Sat, 15 Jul 2017 16:58:05 +0200 Subject: [PATCH] Update webpack config --- src/components/Post.js | 47 ------------------------------------ webpack.prod.config.js | 55 +++++++++++++++++++++--------------------- 2 files changed, 28 insertions(+), 74 deletions(-) delete mode 100644 src/components/Post.js diff --git a/src/components/Post.js b/src/components/Post.js deleted file mode 100644 index d0f3771..0000000 --- a/src/components/Post.js +++ /dev/null @@ -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 ( -
-
-

- {blogPost.title} -

- - {blogPost.published} - - { if (blogPost.updated) { - { blogPost.updated } - }} -
-
- -
-
- ) - } -} diff --git a/webpack.prod.config.js b/webpack.prod.config.js index 7437202..5d0f8a5 100644 --- a/webpack.prod.config.js +++ b/webpack.prod.config.js @@ -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 }) ] }