Skip to content

Commit

Permalink
chore: add webpack files to webpack folder (fixes #133) (#151)
Browse files Browse the repository at this point in the history
* feat: move webpack files to webpack folder

* fix: prefix webpack directory to webpack path

* fix: prefix dot to webpack

* fix: prefix dot to webpack config
  • Loading branch information
Ckbhatia committed Jul 12, 2020
1 parent bfaa5b8 commit 6cb4944
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 54 deletions.
File renamed without changes.
28 changes: 14 additions & 14 deletions webpack.dev.js → .webpack/webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,46 @@ const BrowserConfig = {
entry: './src/client/index.js',
output: {
path: path.resolve(__dirname),
filename: './public/js/app.bundle.js',
publicPath: '/'
filename: '../public/js/app.bundle.js',
publicPath: '/',
},
target: 'web',
devServer: {
historyApiFallback: true
historyApiFallback: true,
},
stats: {
colors: true
colors: true,
},
devtool: 'source-map',
plugins: [
new webpack.DefinePlugin({
__isBrowser__: 'true'
})
]
__isBrowser__: 'true',
}),
],
};

const ServerConfig = {
name: 'server',
entry: './src/server/index.js',
output: {
path: path.resolve(__dirname),
filename: './bin/server.js',
filename: '../bin/server.js',
libraryTarget: 'commonjs2',
publicPath: '/'
publicPath: '/',
},
node: {
__dirname: false
__dirname: false,
},
target: 'node',
plugins: [
new webpack.DefinePlugin({
__isBrowser__: 'false'
})
__isBrowser__: 'false',
}),
],

devServer: {
historyApiFallback: true
}
historyApiFallback: true,
},
};

const browserWebpackConfig = merge(common, BrowserConfig);
Expand Down
36 changes: 36 additions & 0 deletions .webpack/webpack.prod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const merge = require('webpack-merge');
const common = require('./webpack.common.js');
const { resolve } = require('path');
process.env.NODE_ENV = process.env.NODE_ENV || 'production';
const BrowserConfig = {
name: 'browser',
mode: 'production',
entry: './src/client/index.js',
output: {
path: resolve(__dirname),
filename: '../dist/public/js/app.bundle.js',
publicPath: '/',
},
target: 'web',
};

const ServerConfig = {
name: 'server',
entry: './src/server/index.js',
mode: 'production',
output: {
path: resolve(__dirname),
filename: '../dist/server/index.js',
libraryTarget: 'commonjs2',
publicPath: '/',
},
node: {
__dirname: false,
},
target: 'node',
};

const browserWebpackConfig = merge(common, BrowserConfig);
const serverWebpackConfig = merge(common, ServerConfig);

module.exports = [browserWebpackConfig, serverWebpackConfig];
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
"description": "",
"scripts": {
"test": "jest --forceExit ",
"client:start": "webpack-dev-server --mode=development --config webpack.dev.js",
"webpack": "npm run clean && webpack --mode=development --config webpack.dev.js",
"client:start": "webpack-dev-server --mode=development --config .webpack/webpack.dev.js",
"webpack": "npm run clean && webpack --mode=development --config .webpack/webpack.dev.js",
"coveralls": "jest --coverage --forceExit && cat ./coverage/lcov.info | coveralls",
"server:dev": "nodemon NODE_ENV=development --inspect bin/server.js",
"watch": "webpack --watch --mode=development --config webpack.dev.js",
"watch": "webpack --watch --mode=development --config .webpack/webpack.dev.js",
"lint": "eslint . ",
"lint:fix": "eslint . --fix",
"server:prod": "nodemon NODE_ENV=production dist/server",
Expand All @@ -20,7 +20,7 @@
"docker-start:prod": "npm run build && npm run server:prod",
"prod:clean": "rimraf dist",
"prod:build": "make-dir ./dist && make-dir ./dist/server && ncp ./public ./dist/public && make-dir ./dist/public/js",
"build": "cross-env NODE_ENV=production webpack --config webpack.prod.js",
"build": "cross-env NODE_ENV=production webpack --config .webpack/webpack.prod.js",
"prebuild": "npm run prod:clean && npm run prod:build"
},
"jest": {
Expand Down
36 changes: 0 additions & 36 deletions webpack.prod.js

This file was deleted.

0 comments on commit 6cb4944

Please sign in to comment.