1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

fix generating _error.js

This commit is contained in:
nkzawa 2016-10-16 13:01:17 +09:00
parent 3bc8fdecb3
commit 82f23e2aca

View file

@ -15,9 +15,8 @@ export default async function createCompiler(dir, { hotReload = false } = {}) {
}
const errEntry = join('_bundles', 'pages', '_error.js')
if (!entry[errEntry]) {
entry[errEntry] = resolve(__dirname, '..', '..', 'pages', '_error.js')
}
const defaultErrorPath = resolve(__dirname, '..', '..', 'pages', '_error.js')
if (!entry[errEntry]) entry[errEntry] = defaultErrorPath
const nodeModulesDir = resolve(__dirname, '..', '..', '..', 'node_modules')
@ -37,7 +36,10 @@ export default async function createCompiler(dir, { hotReload = false } = {}) {
const loaders = [{
test: /\.js$/,
loader: 'emit-file-loader',
include: dir,
include: [
dir,
resolve(__dirname, '..', '..', 'pages')
],
exclude: /node_modules/,
query: {
name: '[path][name].[ext]'
@ -113,6 +115,12 @@ export default async function createCompiler(dir, { hotReload = false } = {}) {
{ test: /\.json$/, loader: 'json-loader' }
],
loaders
},
customInterpolateName: function (url, name, opts) {
if (defaultErrorPath === this.resourcePath) {
return 'pages/_error.js'
}
return url
}
})
}