Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@orta => Fix static build and deploy #214

Merged
merged 2 commits into from
Aug 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ assets/reaction-force.js
.storybook/manager.js
reaction-force.js
reaction-force.js.map
dist
dist
yarn-error.log
npm-debug.log
12 changes: 10 additions & 2 deletions .storybook/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,17 @@ const { CheckerPlugin } = require("awesome-typescript-loader")
* Write out a file that stubs the data that’s normally shared with the client through the `sharify` module. This file
* is then replaced in the product of webpack where normally the actual `sharify` module would be loaded.
*/
const { METAPHYSICS_ENDPOINT } = env.config().parsed
const { METAPHYSICS_ENDPOINT, NODE_ENV } = env.config().parsed
const sharifyPath = sharify({ METAPHYSICS_ENDPOINT })

/**
* Only use HMR plugin in dev mode
*/
let plugins = [new CheckerPlugin()]
if (NODE_ENV === "development") {
plugins.push(new webpack.HotModuleReplacementPlugin())
}

// A mix of the base from Emission's webpack setup, and the simple config for
// storybooks: https://storybook.js.org/configurations/custom-webpack-config/

Expand Down Expand Up @@ -44,5 +52,5 @@ module.exports = {
},
],
},
plugins: [new CheckerPlugin(), new webpack.HotModuleReplacementPlugin()],
plugins: plugins,
}
21 changes: 4 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,12 @@
"repository": "https://github.com/artsy/reaction-force.git",
"author": "Eloy Durán <[email protected]>",
"license": "MIT",
"files": [
"dist",
"assets",
"data",
"docs"
],
"files": ["dist", "assets", "data", "docs"],
"scripts": {
"start": "node verify-node-version.js && ts-babel-node index.js",
"start:dist": "npm run compile && node index.js ./dist",
"test": "node verify-node-version.js && jest",
"storybook": "node verify-node-version.js && start-storybook -p 9001 -c .storybook -s ./assets",
"storybook": "node verify-node-version.js && start-storybook -p 9001 -c .storybook -s ./assets ",
"deploy-storybook": "storybook-to-ghpages",
"relay2ts": "relay2ts src/components/*.tsx --update",
"sync-schema": "cd externals/metaphysics && git fetch && git checkout origin/master && yarn install && npm run dump-schema -- ../../data",
Expand Down Expand Up @@ -136,17 +131,9 @@
".(ts|tsx)": "typescript-babel-jest"
},
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js"
]
"moduleFileExtensions": ["ts", "tsx", "js"]
},
"lint-staged": {
"*.@(ts|tsx)": [
"tslint --fix",
"npm run prettier-write --",
"git add"
]
"*.@(ts|tsx)": ["tslint --fix", "npm run prettier-write --", "git add"]
}
}
40 changes: 14 additions & 26 deletions webpack/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,26 @@ const path = require("path")
module.exports = () => {
return {
entry: {
"login": [
"babel-polyfill",
"./src/apps/loyalty/containers/login/browser",
],
"inquiries": [
"babel-polyfill",
"./src/apps/loyalty/containers/inquiries/browser",
],
"forgot_password": [
"babel-polyfill",
"./src/apps/loyalty/containers/forgot_password/browser"
],
"analytics": [
"babel-polyfill",
"./src/apps/loyalty/client_side_analytics"
]
login: ["babel-polyfill", "./src/apps/loyalty/containers/login/browser"],
inquiries: ["babel-polyfill", "./src/apps/loyalty/containers/inquiries/browser"],
forgot_password: ["babel-polyfill", "./src/apps/loyalty/containers/forgot_password/browser"],
analytics: ["babel-polyfill", "./src/apps/loyalty/client_side_analytics"],
},
module: {
rules: [
{ test: /\.json$/, loader: "json-loader" },
{
exclude: [/node_modules/, /__stories__/, /__tests__/],
use: [{
loader: "awesome-typescript-loader",
options: {
useBabel: true,
useCache: true,
useTranspileModule: true, // Supposedly faster, won’t work if/when we emit TS declaration files.
use: [
{
loader: "awesome-typescript-loader",
options: {
useBabel: true,
useCache: true,
useTranspileModule: true, // Supposedly faster, won’t work if/when we emit TS declaration files.
},
},
}],
],
test: /\.tsx?$/,
},
],
Expand All @@ -43,9 +33,7 @@ module.exports = () => {
path: path.join(__dirname, "../dist/apps/loyalty/server/bundles"),
publicPath: "/loyalty/bundles",
},
plugins: [
new webpack.optimize.CommonsChunkPlugin("commons.chunk"),
],
plugins: [new webpack.optimize.CommonsChunkPlugin("commons.chunk")],
resolve: {
extensions: [".webpack.js", ".web.js", ".ts", ".tsx", ".js"],
},
Expand Down
32 changes: 13 additions & 19 deletions webpack/development.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,18 @@ module.exports = () => {
return rule.use && rule.use.find(entry => entry.loader === "awesome-typescript-loader")
})

return webpackMerge.smart({
devtool: "inline-source-map",
entry: {
"login": [
"webpack-hot-middleware/client",
],
"inquiries": [
"webpack-hot-middleware/client"
]
return webpackMerge.smart(
{
devtool: "inline-source-map",
entry: {
login: ["webpack-hot-middleware/client"],
inquiries: ["webpack-hot-middleware/client"],
},
module: {
rules: [Object.assign({}, tsLoader, { use: ["react-hot-loader"] })],
},
plugins: [new CheckerPlugin(), new webpack.HotModuleReplacementPlugin()],
},
module: {
rules: [
Object.assign({}, tsLoader, { use: ["react-hot-loader"] }),
],
},
plugins: [
new CheckerPlugin(),
new webpack.HotModuleReplacementPlugin(),
],
}, base)
base
)
}
8 changes: 4 additions & 4 deletions webpack/production.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ module.exports = () => {
plugins: [
new webpack.DefinePlugin({
"process.env": {
"NODE_ENV": JSON.stringify("production"),
NODE_ENV: JSON.stringify("production"),
},
}),
new webpack.optimize.UglifyJsPlugin({
beautify: false,
comments: false,
compress: {
warnings: false
warnings: false,
},
mangle: {
keep_fnames: true
keep_fnames: true,
},
sourceMap: true,
})
}),
],
})
}