Skip to content

Commit

Permalink
Rename webpack configs (#881)
Browse files Browse the repository at this point in the history
* Conformed webpack styles, added loader comments

* Initial renaming

* Fixed incorrect script name

* Added and upated commments to all webpack configs
  • Loading branch information
amilajack authored Mar 31, 2017
1 parent 3ce2666 commit 6a7aac1
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 28 deletions.
20 changes: 11 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
"test-e2e": "cross-env NODE_ENV=test BABEL_DISABLE_CACHE=1 node --trace-warnings ./test/runTests.js e2e",
"lint": "eslint --cache --format=node_modules/eslint-formatter-pretty .",
"lint-fix": "npm run lint -- --fix",
"hot-server": "cross-env NODE_ENV=development node --trace-warnings -r babel-register ./node_modules/webpack-dev-server/bin/webpack-dev-server --config webpack.config.development.js",
"hot-updates-server": "cross-env NODE_ENV=development node --trace-warnings -r babel-register ./node_modules/webpack-dev-server/bin/webpack-dev-server --config webpack.config.renderer.dev.js",
"build": "npm run build-main && npm run build-renderer",
"build-dll": "cross-env NODE_ENV=production node --trace-warnings -r babel-register ./node_modules/webpack/bin/webpack --config webpack.config.dll.js --progress --profile --colors",
"build-main": "cross-env NODE_ENV=production node --trace-warnings -r babel-register ./node_modules/webpack/bin/webpack --config webpack.config.electron.js --progress --profile --colors",
"build-renderer": "cross-env NODE_ENV=production node --trace-warnings -r babel-register ./node_modules/webpack/bin/webpack --config webpack.config.production.js --progress --profile --colors",
"build-dll": "cross-env NODE_ENV=production node --trace-warnings -r babel-register ./node_modules/webpack/bin/webpack --config webpack.config.renderer.dev.dll.js --progress --profile --colors",
"build-main": "cross-env NODE_ENV=production node --trace-warnings -r babel-register ./node_modules/webpack/bin/webpack --config webpack.config.main.prod.js --progress --profile --colors",
"build-renderer": "cross-env NODE_ENV=production node --trace-warnings -r babel-register ./node_modules/webpack/bin/webpack --config webpack.config.renderer.prod.js --progress --profile --colors",
"start": "cross-env NODE_ENV=production electron ./app/",
"flow": "flow",
"flow-typed": "flow-typed install",
"start-hot": "cross-env HOT=1 NODE_ENV=development electron -r babel-register -r babel-polyfill ./app/main.development",
"start-hot-renderer": "cross-env HOT=1 NODE_ENV=development electron -r babel-register -r babel-polyfill ./app/main.development",
"postinstall": "concurrently \"npm run build-dll\" \"install-app-deps\" \"node node_modules/fbjs-scripts/node/check-dev-engines.js package.json\"",
"dev": "cross-env START_HOT=1 npm run hot-server",
"dev": "cross-env START_HOT=1 npm run hot-updates-server",
"package": "npm run build && build --publish never",
"package-win": "npm run build && build --win --x64",
"package-linux": "npm run build && build --linux",
Expand Down Expand Up @@ -90,10 +90,12 @@
"electron",
"boilerplate",
"react",
"react-router",
"flux",
"redux",
"flow",
"sass",
"webpack",
"react-hot"
"hot",
"reload"
],
"homepage": "https://github.com/chentsulin/electron-react-boilerplate#readme",
"jest": {
Expand Down
2 changes: 1 addition & 1 deletion webpack.config.eslint.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
require('babel-register');

module.exports = require('./webpack.config.development');
module.exports = require('./webpack.config.renderer.dev');
2 changes: 1 addition & 1 deletion webpack.config.electron.js → webpack.config.main.prod.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Build config for electron 'Main Process' file
* Webpack config for production electron main process
*/

import webpack from 'webpack';
Expand Down
4 changes: 4 additions & 0 deletions webpack.config.dll.js → webpack.config.renderer.dev.dll.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* Builds the DLL for development electron renderer process
*/

import webpack from 'webpack';
import path from 'path';
import merge from 'webpack-merge';
Expand Down
38 changes: 28 additions & 10 deletions webpack.config.development.js → webpack.config.renderer.dev.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/* eslint global-require: 0, import/no-dynamic-require: 0 */

/**
* Build config for development process that uses Hot-Module-Replacement
* Build config for development electron renderer process that uses
* Hot-Module-Replacement
*
* https://webpack.js.org/concepts/hot-module-replacement/
*/

Expand Down Expand Up @@ -48,7 +50,9 @@ export default merge(baseConfig, {
{
test: /\.global\.css$/,
use: [
{ loader: 'style-loader' },
{
loader: 'style-loader'
},
{
loader: 'css-loader',
options: {
Expand All @@ -60,7 +64,9 @@ export default merge(baseConfig, {
{
test: /^((?!\.global).)*\.css$/,
use: [
{ loader: 'style-loader' },
{
loader: 'style-loader'
},
{
loader: 'css-loader',
options: {
Expand All @@ -72,27 +78,31 @@ export default merge(baseConfig, {
},
]
},

// Add SASS support - compile all .global.scss files and pipe it to style.css
{
test: /\.global\.scss$/,
use: [
{ loader: 'style-loader' },
{
loader: 'style-loader'
},
{
loader: 'css-loader',
options: {
sourceMap: true,
},
},
{ loader: 'sass-loader' }
{
loader: 'sass-loader'
}
]
},

// Add SASS support - compile all other .scss files and pipe it to style.css
{
test: /^((?!\.global).)*\.scss$/,
use: [
{ loader: 'style-loader' },
{
loader: 'style-loader'
},
{
loader: 'css-loader',
options: {
Expand All @@ -102,9 +112,12 @@ export default merge(baseConfig, {
localIdentName: '[name]__[local]__[hash:base64:5]',
}
},
{ loader: 'sass-loader' }
{
loader: 'sass-loader'
}
]
},
// WOFF Font
{
test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
use: {
Expand All @@ -115,6 +128,7 @@ export default merge(baseConfig, {
}
},
},
// WOFF2 Font
{
test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
use: {
Expand All @@ -125,6 +139,7 @@ export default merge(baseConfig, {
}
}
},
// TTF Font
{
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
use: {
Expand All @@ -135,10 +150,12 @@ export default merge(baseConfig, {
}
}
},
// EOT Font
{
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
use: 'file-loader',
},
// SVG Font
{
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
use: {
Expand All @@ -149,6 +166,7 @@ export default merge(baseConfig, {
}
}
},
// Common Image Formats
{
test: /\.(?:ico|gif|png|jpg|jpeg|webp)$/,
use: 'url-loader',
Expand Down Expand Up @@ -222,7 +240,7 @@ export default merge(baseConfig, {
if (process.env.START_HOT) {
spawn(
'npm',
['run', 'start-hot'],
['run', 'start-hot-renderer'],
{ shell: true, env: process.env, stdio: 'inherit' }
)
.on('close', code => process.exit(code))
Expand Down
20 changes: 13 additions & 7 deletions webpack.config.production.js → webpack.config.renderer.prod.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Build config for electron 'Renderer Process' file
* Build config for electron renderer process
*/

import path from 'path';
Expand Down Expand Up @@ -30,7 +30,6 @@ export default merge(baseConfig, {
fallback: 'style-loader',
})
},

// Pipe other styles through css modules and append to style.css
{
test: /^((?!\.global).)*\.css$/,
Expand All @@ -45,7 +44,6 @@ export default merge(baseConfig, {
}
}),
},

// Add SASS support - compile all .global.scss files and pipe it to style.css
{
test: /\.global\.scss$/,
Expand All @@ -54,12 +52,13 @@ export default merge(baseConfig, {
{
loader: 'css-loader'
},
{ loader: 'sass-loader' }
{
loader: 'sass-loader'
}
],
fallback: 'style-loader',
})
},

// Add SASS support - compile all other .scss files and pipe it to style.css
{
test: /^((?!\.global).)*\.scss$/,
Expand All @@ -72,10 +71,12 @@ export default merge(baseConfig, {
localIdentName: '[name]__[local]__[hash:base64:5]',
}
},
{ loader: 'sass-loader' }]
{
loader: 'sass-loader'
}]
}),
},

// WOFF Font
{
test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
use: {
Expand All @@ -86,6 +87,7 @@ export default merge(baseConfig, {
}
},
},
// WOFF2 Font
{
test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
use: {
Expand All @@ -96,6 +98,7 @@ export default merge(baseConfig, {
}
}
},
// TTF Font
{
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
use: {
Expand All @@ -106,10 +109,12 @@ export default merge(baseConfig, {
}
}
},
// EOT Font
{
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
use: 'file-loader',
},
// SVG Font
{
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
use: {
Expand All @@ -120,6 +125,7 @@ export default merge(baseConfig, {
}
}
},
// Common Image Formats
{
test: /\.(?:ico|gif|png|jpg|jpeg|webp)$/,
use: 'url-loader',
Expand Down

0 comments on commit 6a7aac1

Please sign in to comment.