Skip to content

Commit

Permalink
refactor webpack common / develop config
Browse files Browse the repository at this point in the history
  • Loading branch information
thescientist13 committed Apr 18, 2019
1 parent e1943b7 commit 57e6b23
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
10 changes: 6 additions & 4 deletions packages/cli/config/webpack.config.develop.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
const ManifestPlugin = require('webpack-manifest-plugin');
const FilewatcherPlugin = require('filewatcher-webpack-plugin');
const generateCompilation = require('../lib/compile');
const webpackMerge = require('webpack-merge');

const host = 'localhost';
const port = 1981;
const publicPath = '/';
let isRebuilding = false;

const rebuild = async() => {
Expand All @@ -24,11 +24,13 @@ const rebuild = async() => {
};

module.exports = (context) => {
const commonConfig = require(path.join(__dirname, '..', './config/webpack.config.common.js'))(context);
const publicPath = commonConfig.output.publicPath;

return webpackMerge(commonConfig, {

return {
mode: 'development',

// TODO magic strings - .greenwood, app, app.js
entry: [
`webpack-dev-server/client?http://${host}:${port}`,
path.join(context.scratchDir, 'app', 'app.js')
Expand Down Expand Up @@ -74,5 +76,5 @@ module.exports = (context) => {
publicPath
})
]
};
});
};
5 changes: 1 addition & 4 deletions packages/cli/tasks/develop.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
const path = require('path');
const webpack = require('webpack');
const WebpackDevServer = require('webpack-dev-server');
const webpackMerge = require('webpack-merge');

module.exports = runDevServer = async ({ context }) => {
return new Promise(async (resolve, reject) => {

try {
const commonConfig = require(path.join(__dirname, '..', './config/webpack.config.common.js'))(context);
const devConfig = require(path.join(__dirname, '..', './config/webpack.config.develop.js'))(context);
const webpackConfig = webpackMerge(commonConfig, devConfig);
const webpackConfig = require(path.join(__dirname, '..', './config/webpack.config.develop.js'))(context);
const devServerConfig = webpackConfig.devServer;

let compiler = webpack(webpackConfig);
Expand Down

0 comments on commit 57e6b23

Please sign in to comment.