Automatically run flow on build

This commit is contained in:
uwap 2017-10-27 16:40:42 +02:00
parent a65e937623
commit d1dd22eb5d
4 changed files with 32 additions and 8 deletions

View file

@ -4,7 +4,8 @@
"author": "uwap <me@uwap.name>", "author": "uwap <me@uwap.name>",
"description": "react", "description": "react",
"scripts": { "scripts": {
"build": "webpack --bail" "build": "webpack --bail",
"watch": "webpack --watch"
}, },
"dependencies": { "dependencies": {
"babel-preset-env": "^1.6.0", "babel-preset-env": "^1.6.0",
@ -25,7 +26,8 @@
"babel-preset-react": "^6.24.1", "babel-preset-react": "^6.24.1",
"flow": "^0.2.3", "flow": "^0.2.3",
"flow-bin": "^0.50.0", "flow-bin": "^0.50.0",
"webpack": "^3.1.0" "webpack": "^3.1.0",
"webpack-shell-plugin": "^0.5.0"
}, },
"license": "MIT" "license": "MIT"
} }

9
shell.nix Normal file
View file

@ -0,0 +1,9 @@
with (import <nixpkgs> {});
stdenv.mkDerivation rec {
name = "env";
env = buildEnv { name = name; paths = buildInputs; };
buildInputs = with pkgs.nodePackages; [
yarn flow nodejs
];
FLOW_PATH = "${pkgs.flow}/bin/flow";
}

View file

@ -1,25 +1,34 @@
// webpack.config.js: // webpack.config.js:
var path = require('path'); const path = require('path');
var webpack = require('webpack'); 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 = { module.exports = {
resolve: { resolve: {
extensions: ['.js', '.jsx'] extensions: ['.js', '.jsx']
}, },
entry: [ entry: [
path.resolve(__dirname, 'src/index.jsx') path.resolve(__dirname, 'src/index.js')
], ],
output: { output: {
path: path.resolve(__dirname, 'public/dist'), path: path.resolve(__dirname, 'dist'),
filename: 'main.js', filename: 'main.js',
publicPath: 'dist/' publicPath: 'dist/'
}, },
module: { module: {
loaders: [ 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" } { test: /\.js(x)?$/, exclude: /node_modules/, loader: "babel-loader" }
] ]
}, },
plugins: [
new WebpackShellPlugin({onBuildStart:preBuildScripts})
],
devtool: 'source-map' devtool: 'source-map'
} };

View file

@ -3248,6 +3248,10 @@ watchpack@^1.4.0:
chokidar "^1.7.0" chokidar "^1.7.0"
graceful-fs "^4.1.2" 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: webpack-sources@^1.0.1:
version "1.0.1" version "1.0.1"
resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.0.1.tgz#c7356436a4d13123be2e2426a05d1dad9cbe65cf" resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.0.1.tgz#c7356436a4d13123be2e2426a05d1dad9cbe65cf"