Skip to content

Commit

Permalink
Css loader and clean dist
Browse files Browse the repository at this point in the history
  • Loading branch information
geowarin committed Apr 30, 2016
1 parent 22222f7 commit 44f3ced
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/bin/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@

const path = require('path');
const webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const del = require('del');

const rootDir = path.join(__dirname, '../..');
const projectDir = process.cwd();
const distFolder = path.join(projectDir, 'dist');

del.sync(distFolder);

const env = 'production';
const globals = {
Expand All @@ -22,12 +27,13 @@ const config = {
path.join(projectDir, 'src/index')
],
output: {
path: path.join(projectDir, 'dist'),
path: distFolder,
filename: '[name]-[hash].js'
},
plugins: [
new webpack.DefinePlugin(globals),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendors',
minChunks(module) {
Expand All @@ -49,7 +55,7 @@ const config = {
screw_ie8: true
}
}),
new webpack.optimize.DedupePlugin()
new ExtractTextPlugin('style.css')
],
resolve: {
modules: [path.join(projectDir, 'src'), 'node_modules'],
Expand All @@ -71,6 +77,9 @@ const config = {
],
cacheDirectory: true
}
}, {
test: /\.css/,
loader: ExtractTextPlugin.extract('css-loader')
}, {
test: /\.json/,
loaders: ['json']
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"babel-preset-react": "^6.5.0",
"babel-preset-stage-0": "^6.5.0",
"babel-runtime": "^6.6.1",
"css-loader": "^0.23.1",
"del": "^2.2.0",
"extract-text-webpack-plugin": "^1.0.1",
"html-webpack-plugin": "^2.16.0",
"json-loader": "^0.5.4",
"webpack": "^2.1.0-beta.6"
Expand Down

0 comments on commit 44f3ced

Please sign in to comment.