Skip to content
This repository has been archived by the owner on Apr 7, 2022. It is now read-only.

Commit

Permalink
fix(packages/treats): fix webpack server build
Browse files Browse the repository at this point in the history
  • Loading branch information
salmanalfariz24 committed Sep 3, 2019
1 parent 02f1d92 commit 26afba7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
5 changes: 3 additions & 2 deletions packages/treats/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "treats",
"license": "Apache-2.0",
"version": "0.4.2",
"version": "0.4.3",
"description": "Tokopedia React Development Kits",
"author": "Tokopedia Engineering",
"types": "./lib/treats.d.ts",
Expand Down Expand Up @@ -110,7 +110,7 @@
"react-hot-loader": "4.6.0",
"react-intl": "2.7.2",
"react-redux": "5.1.0",
"react-router-dom": "4.3.1",
"react-router-dom": "5.0.0",
"react-universal-component": "3.0.3",
"redux": "4.0.1",
"redux-devtools-extension": "2.13.5",
Expand All @@ -127,6 +127,7 @@
"webpack-dev-server": "3.1.11",
"webpack-flush-chunks": "1.2.3",
"webpack-merge": "4.1.4",
"webpack-node-externals": "1.7.2",
"webpack-source-map-support": "2.0.1",
"winston": "2.4.2",
"workbox-webpack-plugin": "4.1.0",
Expand Down
16 changes: 8 additions & 8 deletions packages/treats/scripts/config/webpack.config.server.build.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const webpack = require("webpack"),
babelMerge = require("babel-merge"),
webpackMerge = require("webpack-merge"),
extractEnv = require("./util/extract-env"),
useTypescript = fs.pathExistsSync(path.resolve(process.cwd(), "./tsconfig.json"));
useTypescript = fs.pathExistsSync(path.resolve(process.cwd(), "./tsconfig.json")),
nodeExternals = require("webpack-node-externals");

module.exports = ({
alias,
Expand Down Expand Up @@ -40,13 +41,12 @@ module.exports = ({
...resolve,
alias
},
externals: fs
.readdirSync("./node_modules")
.filter(x => !/\.bin|react-universal-component|webpack-flush-chunks|treats/.test(x))
.reduce((externals, mod) => {
externals[mod] = `commonjs ${mod}`;
return externals;
}, {}),
externals: nodeExternals({
whitelist: [
/\.bin|react-universal-component|webpack-flush-chunks|treats/,
/babel-plugin-universal-import|react-universal-component/
]
}),
node: {
__dirname: false
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const webpack = require("webpack"),
babelMerge = require("babel-merge"),
webpackMerge = require("webpack-merge"),
extractEnv = require("./util/extract-env"),
useTypescript = fs.pathExistsSync(path.resolve(process.cwd(), "./tsconfig.json"));
useTypescript = fs.pathExistsSync(path.resolve(process.cwd(), "./tsconfig.json")),
nodeExternals = require("webpack-node-externals");

module.exports = ({
alias,
Expand All @@ -33,13 +34,13 @@ module.exports = ({
mode: "development",
devtool: "cheap-eval-source-map",
entry: ["webpack/hot/signal?1000", path.join(alias["@treats/server"], "./entry")],
externals: fs
.readdirSync("./node_modules")
.filter(x => !/\.bin|react-universal-component|webpack-flush-chunks|treats/.test(x))
.reduce((externals, mod) => {
externals[mod] = `commonjs ${mod}`;
return externals;
}, {}),
externals: nodeExternals({
whitelist: [
/\.bin|react-universal-component|webpack-flush-chunks|treats/,
/babel-plugin-universal-import|react-universal-component/,
"webpack/hot/signal?1000"
]
}),
watch: true,
resolve: {
...resolve,
Expand Down

0 comments on commit 26afba7

Please sign in to comment.