add webpack build pipeline for react

pull/9/head
unknown 2018-10-28 16:42:38 -04:00
parent e576187e2f
commit a2236785d1
8 changed files with 82 additions and 117 deletions

4
.babelrc Normal file
View File

@ -0,0 +1,4 @@
{
"presets": ["@babel/preset-env", "@babel/preset-react"],
"plugins": ["@babel/plugin-proposal-object-rest-spread"]
}

114
.gitignore vendored
View File

@ -1,119 +1,7 @@
################################################
# ┌─┐┬┌┬┐╦╔═╗╔╗╔╔═╗╦═╗╔═╗
# │ ┬│ │ ║║ ╦║║║║ ║╠╦╝║╣
# o└─┘┴ ┴ ╩╚═╝╝╚╝╚═╝╩╚═╚═╝
#
# > Files to exclude from your app's repo.
#
# This file (`.gitignore`) is only relevant if
# you are using git.
#
# It exists to signify to git that certain files
# and/or directories should be ignored for the
# purposes of version control.
#
# This keeps tmp files and sensitive credentials
# from being uploaded to your repository. And
# it allows you to configure your app for your
# machine without accidentally committing settings
# which will smash the local settings of other
# developers on your team.
#
# Some reasonable defaults are included below,
# but, of course, you should modify/extend/prune
# to fit your needs!
#
################################################
################################################
# Local Configuration
#
# Explicitly ignore files which contain:
#
# 1. Sensitive information you'd rather not push to
# your git repository.
# e.g., your personal API keys or passwords.
#
# 2. Developer-specific configuration
# Basically, anything that would be annoying
# to have to change every time you do a
# `git pull` on your laptop.
# e.g. your local development database, or
# the S3 bucket you're using for file uploads
# during development.
#
################################################
config/local.js
################################################
# Dependencies
#
#
# When releasing a production app, you _could_
# hypothetically include your node_modules folder
# in your git repo, but during development, it
# is always best to exclude it, since different
# developers may be working on different kernels,
# where dependencies would need to be recompiled
# anyway.
#
# Most of the time, the node_modules folder can
# be excluded from your code repository, even
# in production, thanks to features like the
# package-lock.json file / NPM shrinkwrap.
#
# But no matter what, since this is a Sails app,
# you should always push up the package-lock.json
# or shrinkwrap file to your repository, to avoid
# accidentally pulling in upgraded dependencies
# and breaking your code.
#
# That said, if you are having trouble with
# dependencies, (particularly when using
# `npm link`) this can be pretty discouraging.
# But rather than just adding the lockfile to
# your .gitignore, try this first:
# ```
# rm -rf node_modules
# rm package-lock.json
# npm install
# ```
#
# [?] For more tips/advice, come by and say hi
# over at https://sailsjs.com/support
#
################################################
node_modules
################################################
#
# > Do you use bower?
# > re: the bower_components dir, see this:
# > http://addyosmani.com/blog/checking-in-front-end-dependencies/
# > (credit Addy Osmani, @addyosmani)
#
################################################
################################################
# Temporary files generated by Sails/Waterline.
################################################
.tmp
################################################
# Miscellaneous
#
# Common files generated by text editors,
# operating systems, file systems, dbs, etc.
################################################
*~
*#
.DS_STORE
@ -123,7 +11,7 @@ nbproject
.node_history
dump.rdb
npm-debug.log
npm-debug.log.*
lib-cov
*.seed
*.log

View File

@ -5,5 +5,8 @@
"_generatedWith": {
"sails": "1.0.2",
"sails-generate": "1.15.28"
},
"hooks": {
"grunt": false
}
}

11
assets/js/login.js Normal file
View File

@ -0,0 +1,11 @@
import React from 'react';
import ReactDOM from 'react-dom';
const App = () => {
return (
<div>
login.js
</div>
);
};
ReactDOM.render(<App />, document.getElementById('root'));

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Sails React</title>
</head>
<body>
<div id="root"></div>
</body>
</html>

View File

@ -12,20 +12,39 @@
"express-rate-limit": "^3.2.1",
"forever": "^0.15.3",
"grunt": "^1.0.3",
"react": "^16.6.0",
"react-dom": "^16.6.0",
"sails": "^1.0.2",
"sails-hook-grunt": "^3.0.2",
"sails-hook-orm": "^2.1.1",
"sails-hook-sockets": "^1.4.0"
},
"devDependencies": {
"@sailshq/eslint": "^4.19.3"
"@babel/core": "^7.1.2",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/preset-env": "^7.1.0",
"@babel/preset-react": "^7.0.0",
"@sailshq/eslint": "^4.19.3",
"babel-loader": "^8.0.4",
"html-webpack-plugin": "^3.2.0",
"npm-run-all": "^4.1.3",
"rimraf": "^2.6.2",
"webpack": "^4.23.1",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.10"
},
"scripts": {
"start": "sudo NODE_ENV='production' ./node_modules/.bin/forever start app.js",
"stop": "./node_modules/.bin/forever stopall",
"start": "npm-run-all --parallel open:client lift",
"start:debug": "npm-run-all --parallel open:client debug",
"open:client": "webpack-dev-server --mode development",
"build": "npm run build:prod",
"build:dev": "webpack --mode development",
"build:prod": "webpack --mode production",
"clean": "rimraf .tmp && mkdirp .tmp/public",
"lift": "sails lift",
"test": "npm run lint && npm run custom-tests && echo 'Done.'",
"lint": "eslint . --max-warnings=0 --report-unused-disable-directives && echo '✔ Your .js files look good.'",
"custom-tests": "echo \"(No other custom tests yet.)\" && echo"
"debug": "node --inspect app.js"
},
"main": "app.js",
"repository": {

1
views/pages/login.ejs Normal file
View File

@ -0,0 +1 @@
<%- partial('../../.tmp/public/login.html') %>

29
webpack.config.js Normal file
View File

@ -0,0 +1,29 @@
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: {
login: './assets/js/login.js'
},
output: {
path: __dirname + '/.tmp/public',
filename: '[name].bundle.js'
},
module: {
rules: [
{
use: 'babel-loader',
test: /\.jsx?$/,
exclude: /node_modules/
},
{
use: ['style-loader', 'css-loader'],
test: /\.css$/
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: 'assets/templates/login.html'
})
]
};