Copy boilerplate to the popup dir

This commit is contained in:
Ilya Ig. Petrov 2017-05-10 10:59:45 +05:00
parent d7a7fcf310
commit 24e3400376
7 changed files with 2503 additions and 0 deletions

View File

@ -0,0 +1,8 @@
[ignore]
.*/test/.*
[include]
[libs]
[options]

View File

@ -0,0 +1,4 @@
node_modules
npm-debug.log
.swp
dist

View File

@ -0,0 +1,11 @@
# React + Flow + Webpack 2 Boilerplate with Babel
Switch branches for adding/removing Babel for JSX + Flowtype.
## Install
`yarn install` or `npm install --dev`
## Run
`yarn/npm run build`

View File

@ -0,0 +1,24 @@
{
"name": "hello-react",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"devDependencies": {
"babel-cli": "^6.24.1",
"babel-loader": "^7.0.0",
"babel-preset-flow": "^6.23.0",
"babel-preset-react": "^6.24.1",
"babili-webpack-plugin": "^0.0.11",
"flow-bin": "^0.45.0",
"react": "^15.5.4",
"react-dom": "^15.5.4",
"webpack": "^2.5.1"
},
"scripts": {
"check": "flow status",
"build:prod": "webpack --define process.env.NODE_ENV=\"'production'\" --env=prod",
"build:dev:nocomp": "webpack --define process.env.NODE_ENV=\"'production'\" --env=dev",
"build:dev": "webpack --debug --devtool source-map --output-pathinfo --env=dev",
"build": "npm run build:dev"
}
}

View File

@ -0,0 +1,15 @@
// @flow
import React from 'react';
import ReactDOM from 'react-dom';
let x:string; // webpack/babel must remove type here!
x = 'Search me in the compiled bundle!';
let t:string;
t = 12345; // Flow must detect error here!
// webpack/babel must transpile JSX to JS below:
ReactDOM.render(
<h1>Hello from React WITH BABEL</h1>,
document.getElementById('root')
);

View File

@ -0,0 +1,31 @@
'use strict';
const path = require('path');
const BabiliPlugin = require('babili-webpack-plugin');
module.exports = (env, ...flags) => ({
entry: './src/index.js',
output: {
path: path.join(__dirname, 'dist'),
filename: `bundle${env === 'prod' ? '.min' : ''}.js`,
},
module: {
rules: [
{
test: /\.jsx?$/,
include: path.join(__dirname, 'src'),
use: [{
loader: 'babel-loader',
options: { presets: ['react', 'flow'] },
}],
}
],
},
plugins: env === 'prod' ?
[
/* Production */
new BabiliPlugin(),
] : [
/* Development */
],
});