This repository has been archived by the owner on Oct 1, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Perform development environment cleanup
Get rid of universal-webpack
- Loading branch information
1 parent
4b392c6
commit d8f4d4f
Showing
29 changed files
with
731 additions
and
720 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
if (process.env.NODE_ENV === 'production') { | ||
process.exit(1); | ||
} | ||
|
||
process.env.NODE_ENV = 'development'; | ||
|
||
// Error.stackTraceLimit = Infinity; | ||
require('trace'); | ||
require('clarify'); | ||
|
||
const bb = require('bluebird'); | ||
require('babel-runtime/core-js/promise').default = bb; | ||
global.Promise = bb; | ||
|
||
require('./utils/hook'); | ||
require('./utils/watch'); | ||
|
||
require('../server')(), | ||
require('../tasks')(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,5 @@ | ||
if (process.env.NODE_ENV === 'development') { | ||
// Error.stackTraceLimit = Infinity; | ||
require('trace'); | ||
require('clarify'); | ||
} | ||
|
||
const bb = require('bluebird'); | ||
|
||
require('babel-runtime/core-js/promise').default = bb; | ||
global.Promise = bb; | ||
|
||
require("babel-register")({ | ||
ignore: /\/(public|node_modules)\// | ||
}); | ||
|
||
const { server } = require('universal-webpack'); | ||
|
||
const settings = require('../server-uwsettings'); | ||
const configuration = require('../webpack.config.server.babel').default; | ||
|
||
server(configuration, settings); | ||
require('../public/server/server')(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,5 @@ | ||
if (process.env.NODE_ENV === 'development') { | ||
Error.stackTraceLimit = Infinity; | ||
require('trace'); | ||
require('clarify'); | ||
} | ||
|
||
const bb = require('bluebird'); | ||
|
||
require('babel-runtime/core-js/promise').default = bb; | ||
global.Promise = bb; | ||
|
||
require("babel-register")({ | ||
ignore: /\/(public|node_modules)\// | ||
}); | ||
|
||
const { server } = require('universal-webpack'); | ||
|
||
const settings = require('../tasks-uwsettings'); | ||
const configuration = require('../webpack.config.server.babel').default; | ||
|
||
server(configuration, settings); | ||
require('../public/server/tasks')(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const fs = require('fs'); | ||
const addHook = require('asset-require-hook/lib/hook'); | ||
const assetRequireHook = require('asset-require-hook'); | ||
const babelRegisterHook = require("babel-register"); | ||
|
||
function rawLoader(resourcePath) { | ||
const content = fs.readFileSync(resourcePath, 'utf-8'); | ||
return content; | ||
} | ||
|
||
// attachHook(rawLoader, '.ejs'); | ||
addHook('.ejs', rawLoader); | ||
|
||
assetRequireHook({ | ||
extensions: ['.png', 'jpg', '.gif', '.svg'], | ||
name: 'assets/images/[name]-[hash].[ext]', | ||
publicPath: '/' | ||
}); | ||
|
||
assetRequireHook({ | ||
extensions: ['.ico'], | ||
name: '[name]-[hash].[ext]', | ||
publicPath: '/' | ||
}); | ||
|
||
babelRegisterHook({ ignore: /\/(public|node_modules)\// }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const path = require('path'); | ||
|
||
const watcher = require('chokidar') | ||
.watch([ | ||
path.join(__dirname, '../../src/api'), | ||
path.join(__dirname, '../../src/utils') | ||
]); | ||
|
||
watcher.on('ready', () => { | ||
watcher.on('all', () => { | ||
// eslint-disable-next-line no-console | ||
console.log('Clearing server module cache from server'); | ||
Object.keys(require.cache).forEach(id => { | ||
if (/[/\\]src[/\\](api|utils)/.test(id)) { | ||
delete require.cache[id]; | ||
} | ||
}); | ||
}); | ||
}); | ||
|
||
/* Optional: "hot-reloading" of client related modules on the server | ||
const compiler = require('webpack')(require('../../res/webpack/client.js')); | ||
compiler.plugin('done', () => { | ||
// Need to separate client and server code to prevent unnecessary reloads | ||
}); | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
This file is a part of libertysoil.org website | ||
Copyright (C) 2017 Loki Education (Social Enterprise) | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
const path = require('path'); | ||
const merge = require('lodash/merge'); | ||
const webpack = require('webpack'); | ||
|
||
const | ||
NODE_ENV = process.env.NODE_ENV, | ||
__DEV__ = NODE_ENV !== 'production', | ||
context = path.join(__dirname, '../../'); | ||
|
||
// console.log(NODE_ENV); | ||
|
||
const baseConfiguration = { | ||
context, | ||
module: { | ||
noParse: /\.min\.js$/ | ||
}, | ||
output: { | ||
filename: '[name].js', | ||
publicPath: '/' | ||
}, | ||
performance: { | ||
hints: false | ||
}, | ||
plugins: [ | ||
new webpack.DefinePlugin({ | ||
'process.env': { | ||
'NODE_ENV': JSON.stringify(NODE_ENV) | ||
} | ||
}), | ||
new webpack.NoEmitOnErrorsPlugin(), | ||
new webpack.LoaderOptionsPlugin({ | ||
debug: __DEV__, | ||
minimize: !__DEV__, | ||
options: { | ||
context | ||
} | ||
}) | ||
], | ||
stats: { | ||
assets: false, | ||
cached: false, | ||
children: false, | ||
chunks: true, | ||
chunkOrigins: false, | ||
modules: false, | ||
reasons: false, | ||
source: false, | ||
timings: true | ||
} | ||
}; | ||
|
||
if (__DEV__) { | ||
merge(baseConfiguration, { | ||
performance: { | ||
hints: 'warning' | ||
} | ||
}); | ||
} | ||
|
||
module.exports = baseConfiguration; |
Oops, something went wrong.