From 960587f1488747876b9b9a4f560b74f250eaa6ea Mon Sep 17 00:00:00 2001 From: ewnd9 Date: Mon, 15 Feb 2016 17:57:11 +0800 Subject: [PATCH] migrate to webpackman --- package.json | 16 +++------ webpack.config.js | 84 ----------------------------------------------- 2 files changed, 4 insertions(+), 96 deletions(-) delete mode 100644 webpack.config.js diff --git a/package.json b/package.json index c8df5cc..beb944a 100644 --- a/package.json +++ b/package.json @@ -6,11 +6,12 @@ "bin": "cli.js", "scripts": { "start": "npm-run-all --parallel start:frontend start:backend", - "start:frontend": "webpack-dev-server --hot --inline", + "start:frontend": "wserve --x-entry frontend/app.js --x-html frontend/index.html --x-dist public", "start:backend": "npm-run-all --parallel build:backend:watch start:nodemon", "start:nodemon": "nodemon --watch lib app.js", "build:backend": "babel -s -d lib src", "build:backend:watch": "babel --watch -s -d lib src", + "build:frontend": "rm -rf public/* && NODE_ENV=production wbuild --x-entry frontend/app.js --x-html frontend/index.html --x-dist public", "style": "eslint src/ frontend/", "test": "ava ./test/*.js", "test:watch": "nodemon test/*.js --exec ava" @@ -54,25 +55,21 @@ }, "devDependencies": { "alertify.js": "^1.0.8", - "autoprefixer": "^6.2.3", "ava": "^0.9.1", "babel-cli": "^6.4.0", "babel-core": "^6.4.0", "babel-eslint": "^5.0.0-beta9", - "babel-loader": "^6.2.1", "babel-plugin-transform-runtime": "^6.4.0", "babel-polyfill": "^6.5.0", "babel-preset-es2015": "^6.3.13", "babel-preset-react": "^6.3.13", + "babel-preset-react-hmre": "^1.1.0", "babel-preset-stage-0": "^6.3.13", "bootstrap": "^3.3.6", "chai": "^3.2.0", "classnames": "^2.2.3", - "css-loader": "^0.23.0", "eslint": "^1.10.3", "eslint-plugin-react": "^3.14.0", - "extract-text-webpack-plugin": "^1.0.1", - "file-loader": "^0.8.5", "got": "^6.0.1", "isomorphic-fetch": "^2.2.0", "mocha": "^2.2.5", @@ -82,9 +79,7 @@ "node-notifier": "^4.4.0", "nodemon": "^1.8.1", "npm-run-all": "^1.4.0", - "postcss-loader": "^0.8.0", "pre-commit": "^1.1.2", - "precss": "^1.4.0", "proxyquire": "^1.7.3", "react": "^0.14.4", "react-dom": "^0.14.4", @@ -95,10 +90,7 @@ "script-loader": "^0.6.1", "sinon": "^1.17.2", "socket.io-client": "^1.4.2", - "style-loader": "^0.13.0", - "url-loader": "^0.5.7", - "webpack": "^1.12.9", - "webpack-dev-server": "^1.14.0" + "webpackman": "^0.1.0" }, "pre-commit": [ "style" diff --git a/webpack.config.js b/webpack.config.js deleted file mode 100644 index 711e514..0000000 --- a/webpack.config.js +++ /dev/null @@ -1,84 +0,0 @@ -var path = require('path'); -var webpack = require('webpack'); -var ExtractTextPlugin = require('extract-text-webpack-plugin'); -var autoprefixer = require('autoprefixer'); -var precss = require('precss'); - -var NODE_ENV = process.env.NODE_ENV || 'development'; - -var plugins = [ - new webpack.DefinePlugin({ - 'process.env': { - 'NODE_ENV': JSON.stringify(NODE_ENV) - } - }), - new webpack.ProvidePlugin({ - 'Promise': 'bluebird', - 'window.Promise': 'bluebird' - }), - new ExtractTextPlugin('styles.css') -]; - -if (process.env.NODE_ENV === 'production') { - plugins.push( - new webpack.optimize.UglifyJsPlugin({ - compressor: { - screw_ie8: true, - warnings: false - } - }) - ); -} - -module.exports = { - entry: { - app: './frontend/app.js', - html: './frontend/index.html' - }, - devtool: 'cheap-module-source-map', - output: { - filename: '[name].bundle.js', - sourceMapFilename: '[file].map', - path: './public' - }, - resolve: { - root: [ - path.join(__dirname, 'frontend'), - path.join(__dirname, 'node_modules'), - ], - moduleDirectories: [ - 'node_modules' - ] - }, - module: { - loaders: [ - { - test: /\.jsx?$/, - exclude: /(node_modules|bower_components)/, - loaders: [ - 'react-hot', - 'babel' - ] - }, - { - test: /\.html$/, - loader: "file?name=[name].[ext]", - }, - { - test: /\.css$/, - loader: ExtractTextPlugin.extract('style-loader', 'css-loader!postcss-loader') - }, - { test: /\.woff2?(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/font-woff" }, - { test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/octet-stream" }, - { test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: "file" }, - { test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=image/svg+xml" } - ] - }, - plugins: plugins, - postcss: [autoprefixer, precss], - devServer: { - contentBase: "./public", - noInfo: true, // --no-info option - hot: true - } -};