balena-supervisor/hardcode-migrations.js
Pablo Carranza Velez 35e11de69d Fix webpack loader for knex migrations so it works with knex 0.15.2
Signed-off-by: Pablo Carranza Velez <pablo@balena.io>
2018-12-12 13:42:31 -03:00

10 lines
462 B
JavaScript

// knex migrations use dynamic requires which break with webpack.
// This hack makes the migrations directory a constant so that at least we can use webpack contexts for the
// require.
module.exports = function (source) {
return source
.toString()
.replace(/require\(_path2\.default\.join\(_?this\._absoluteConfigDir\(\), name\)\);/g, "require('./migrations/' + name);")
.replace("require(directory + '/' + name);", "require('./migrations/' + name);")
}