From 44f3ced9e734fc5391b1f09e092373f4b64f04ea Mon Sep 17 00:00:00 2001 From: geowarin Date: Sat, 30 Apr 2016 13:59:21 +0200 Subject: [PATCH] Css loader and clean dist --- lib/bin/react.js | 15 ++++++++++++--- package.json | 3 +++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/bin/react.js b/lib/bin/react.js index 1c242bb..94400e7 100755 --- a/lib/bin/react.js +++ b/lib/bin/react.js @@ -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 = { @@ -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) { @@ -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'], @@ -71,6 +77,9 @@ const config = { ], cacheDirectory: true } + }, { + test: /\.css/, + loader: ExtractTextPlugin.extract('css-loader') }, { test: /\.json/, loaders: ['json'] diff --git a/package.json b/package.json index 6829faf..030fccd 100644 --- a/package.json +++ b/package.json @@ -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"