diff --git a/package.json b/package.json index ff20410..a1e3c3f 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "author": "uwap ", "description": "react", "scripts": { - "build": "webpack --bail" + "build": "webpack --bail", + "watch": "webpack --watch" }, "dependencies": { "babel-preset-env": "^1.6.0", @@ -25,7 +26,8 @@ "babel-preset-react": "^6.24.1", "flow": "^0.2.3", "flow-bin": "^0.50.0", - "webpack": "^3.1.0" + "webpack": "^3.1.0", + "webpack-shell-plugin": "^0.5.0" }, "license": "MIT" } diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..ebd3f13 --- /dev/null +++ b/shell.nix @@ -0,0 +1,9 @@ +with (import {}); +stdenv.mkDerivation rec { + name = "env"; + env = buildEnv { name = name; paths = buildInputs; }; + buildInputs = with pkgs.nodePackages; [ + yarn flow nodejs + ]; + FLOW_PATH = "${pkgs.flow}/bin/flow"; +} diff --git a/webpack.config.js b/webpack.config.js index 2110d8a..4126c0f 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,25 +1,34 @@ // webpack.config.js: -var path = require('path'); -var webpack = require('webpack'); +const path = require('path'); +const webpack = require('webpack'); +const WebpackShellPlugin = require('webpack-shell-plugin'); + +const preBuildScripts = process.env.NO_FLOW == undefined ? + process.env.FLOW_PATH != undefined ? [process.env.FLOW_PATH] : ['flow'] + : []; module.exports = { resolve: { extensions: ['.js', '.jsx'] }, entry: [ - path.resolve(__dirname, 'src/index.jsx') + path.resolve(__dirname, 'src/index.js') ], output: { - path: path.resolve(__dirname, 'public/dist'), + path: path.resolve(__dirname, 'dist'), filename: 'main.js', publicPath: 'dist/' }, module: { loaders: [ - { test: /\.css$/, loader: "style!css" }, + { test: /\.(woff2?|eot|ttf|svg)$/, loader: "file-loader" }, + { test: /\.css$/, loader: "style-loader!css-loader" }, { test: /\.js(x)?$/, exclude: /node_modules/, loader: "babel-loader" } ] }, + plugins: [ + new WebpackShellPlugin({onBuildStart:preBuildScripts}) + ], devtool: 'source-map' -} +}; diff --git a/yarn.lock b/yarn.lock index 8f55f4e..fa8b9ef 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3248,6 +3248,10 @@ watchpack@^1.4.0: chokidar "^1.7.0" graceful-fs "^4.1.2" +webpack-shell-plugin@^0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/webpack-shell-plugin/-/webpack-shell-plugin-0.5.0.tgz#29b8a1d80ddeae0ddb10e729667f728653c2c742" + webpack-sources@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.0.1.tgz#c7356436a4d13123be2e2426a05d1dad9cbe65cf"