Skip to content

Commit

Permalink
Check also the webpack config and the server code
Browse files Browse the repository at this point in the history
  • Loading branch information
julienw committed Jun 29, 2017
1 parent d963c4f commit df4b389
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 43 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ module.exports = {
// overriding recommended rules
"no-constant-condition": ["error", { checkLoops: false }],
"no-console": [ "error", { allow: ["log", "warn", "error"] } ],
"no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],

// possible errors
"array-callback-return": "error",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"build-prod": "yarn run build:clean && NODE_ENV=production webpack -p --progress",
"build-prod-readable": "yarn run build:clean && NODE_ENV=production webpack --progress",
"build-docs": "documentation build src/types/profile.js -f md > docs/processed-profile-format.md; cat docs/processed-profile-format.md",
"eslint": "eslint index.js src",
"eslint": "eslint *.js src",
"eslint-fix": "yarn eslint -- --fix",
"flow": "flow",
"flow-coverage": "flow-coverage-report -i 'src/**/*.js' -t html -t text",
Expand Down
6 changes: 4 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ new WebpackDevServer(webpack(config), {
stats: {
colors: true,
},
}).listen(port, 'localhost', function (err) {
}).listen(port, 'localhost', function(err) {
if (err) {
console.log(err);
}

console.log(`Listening at localhost:${port}`);
if (port === 4242) {
console.log('You can change this default port with the environment variable PERFHTML_PORT.');
console.log(
'You can change this default port with the environment variable PERFHTML_PORT.'
);
}
});
82 changes: 42 additions & 40 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@ const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const OfflinePlugin = require('offline-plugin');
const includes = [
path.join(__dirname, 'src'),
path.join(__dirname, 'res'),
];
const includes = [path.join(__dirname, 'src'), path.join(__dirname, 'res')];

const es6modules = [
'pretty-bytes',
];
const es6modules = ['pretty-bytes'];
const es6modulePaths = es6modules.map(module => {
return path.join(__dirname, 'node_modules', module);
});
Expand All @@ -36,33 +31,40 @@ const baseConfig = {
alias: {
'redux-devtools/lib': path.join(__dirname, '..', '..', 'src'),
'redux-devtools': path.join(__dirname, '..', '..', 'src'),
'react': path.join(__dirname, 'node_modules', 'react'),
react: path.join(__dirname, 'node_modules', 'react'),
},
extensions: ['.js'],
},
module: {
rules: [{
test: /\.js$/,
loaders: ['babel-loader'],
include: includes.concat(es6modulePaths),
}, {
test: /\.json$/,
loaders: ['json-loader'],
include: includes,
}, {
test: /\.css?$/,
loaders: ['style-loader', 'css-loader?minimize'],
include: includes,
}, {
test: /\.jpg$/,
loader: 'file-loader',
}, {
test: /\.png$/,
loader: 'file-loader',
}, {
test: /\.svg$/,
loader: 'file-loader',
}],
rules: [
{
test: /\.js$/,
loaders: ['babel-loader'],
include: includes.concat(es6modulePaths),
},
{
test: /\.json$/,
loaders: ['json-loader'],
include: includes,
},
{
test: /\.css?$/,
loaders: ['style-loader', 'css-loader?minimize'],
include: includes,
},
{
test: /\.jpg$/,
loader: 'file-loader',
},
{
test: /\.png$/,
loader: 'file-loader',
},
{
test: /\.svg$/,
loader: 'file-loader',
},
],
},
node: {
process: false,
Expand All @@ -71,7 +73,9 @@ const baseConfig = {

if (process.env.NODE_ENV === 'development') {
baseConfig.devtool = 'source-map';
baseConfig.entry = ['webpack-dev-server/client?http://localhost:4242'].concat(baseConfig.entry);
baseConfig.entry = ['webpack-dev-server/client?http://localhost:4242'].concat(
baseConfig.entry
);
}

const contentConfig = Object.assign({}, baseConfig, {
Expand All @@ -80,10 +84,9 @@ const contentConfig = Object.assign({}, baseConfig, {
title: 'perf.html',
template: 'res/index.html',
favicon: 'res/favicon.png',
})),
entry: [
'./src/index',
],
})
),
entry: ['./src/index'],
output: {
path: path.join(__dirname, 'dist'),
filename: '[hash].bundle.js',
Expand All @@ -105,19 +108,18 @@ if (process.env.NODE_ENV === 'production') {
cacheMaps: [
{
requestTypes: null,
match: function (url, request) {
match: function(url, _request) {
return url.origin === location.origin ? url.origin + '/' : null;
},
},
],
}));
})
);
}

const workerConfig = Object.assign({}, baseConfig, {
plugins: basePlugins.slice(0),
entry: [
'./src/profile-logic/summary-worker/index',
],
entry: ['./src/profile-logic/summary-worker/index'],
output: {
path: path.join(__dirname, 'dist'),
filename: 'worker.js',
Expand Down

0 comments on commit df4b389

Please sign in to comment.