Skip to content

Commit

Permalink
Move webpack configs to their folder
Browse files Browse the repository at this point in the history
  • Loading branch information
karelhala committed May 22, 2018
1 parent 0f50965 commit 6d35298
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 23 deletions.
16 changes: 16 additions & 0 deletions config/webpack.common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const path = require('path');
const entry = process.env.NODE_ENV === 'production' ?
path.resolve(__dirname, '../src/entry.js') :
path.resolve(__dirname, '../src/entry-dev.js');

module.exports = {
paths: {
entry: entry,
public: path.resolve(__dirname, '../dist'),
src: path.resolve(__dirname, '../src'),
dumbComponents: path.resolve(__dirname, '../src/DumbComponents'),
smartComponents: path.resolve(__dirname, '../src/SmartComponents'),
pages: path.resolve(__dirname, '../src/pages'),
static: path.resolve(__dirname, '../static')
}
};
4 changes: 2 additions & 2 deletions webpack.config.js → config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const merge = require('lodash/merge');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const config = require('./webpack.common.js');
const { resolve } = require('path');
const pkg = require('./package.json');
const pkg = require('../package.json');

const webpack_config = {
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
Expand Down Expand Up @@ -46,7 +46,7 @@ const webpack_config = {
options: {
includePaths: [
...Object.values(pkg.sassIncludes).map(includePath =>
resolve(__dirname, `./${includePath}`)
resolve(__dirname, `../${includePath}`)
)
]
}
Expand Down
4 changes: 2 additions & 2 deletions webpack.plugins.js → config/webpack.plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ plugins.push(WriteFileWebpackPlugin);
const HtmlWebpackPlugin = new (require('html-webpack-plugin'))({
title: 'My App',
filename: 'index.html',
template: path.resolve(__dirname, 'src/index.html')
template: path.resolve(__dirname, '../src/index.html')
});
plugins.push(HtmlWebpackPlugin);

Expand Down Expand Up @@ -86,7 +86,7 @@ plugins.push(ExtractCssWebpackPlugin);
* Copies files from the specified locations to the corresponding destinations.
*/
const CopyFilesWebpackPlugin = new (require('copy-webpack-plugin'))([
{from: './static/images', to: 'images'}
{from: path.resolve(__dirname, '../static/images'), to: 'images'}
]);
plugins.push(CopyFilesWebpackPlugin);

Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@
"write-file-webpack-plugin": "^4.2.0"
},
"scripts": {
"start": "webpack-dev-server --mode development",
"prod": "webpack-dev-server --mode production",
"start": "webpack-dev-server --mode development --config config/webpack.config.js",
"prod": "webpack-dev-server --mode production --config config/webpack.config.js",
"server:ctr": "node src/server/generateServerKey.js",
"build": "webpack"
"build": "webpack --config config/webpack.config.js"
}
}
16 changes: 0 additions & 16 deletions webpack.common.js

This file was deleted.

0 comments on commit 6d35298

Please sign in to comment.