mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
webpack: emit json and apply json-loader after emitting files (#298)
This commit is contained in:
parent
f9726a5d59
commit
fc369fa240
|
@ -74,18 +74,7 @@ export default async function createCompiler (dir, { hotReload = false, dev = fa
|
||||||
const babelRuntimePath = require.resolve('babel-runtime/package')
|
const babelRuntimePath = require.resolve('babel-runtime/package')
|
||||||
.replace(/[\\/]package\.json$/, '')
|
.replace(/[\\/]package\.json$/, '')
|
||||||
|
|
||||||
const loaders = [{
|
const loaders = (hotReload ? [{
|
||||||
test: /\.js$/,
|
|
||||||
loader: 'emit-file-loader',
|
|
||||||
include: [dir, nextPagesDir],
|
|
||||||
exclude (str) {
|
|
||||||
return /node_modules/.test(str) && str.indexOf(nextPagesDir) !== 0
|
|
||||||
},
|
|
||||||
query: {
|
|
||||||
name: 'dist/[path][name].[ext]'
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
.concat(hotReload ? [{
|
|
||||||
test: /\.js$/,
|
test: /\.js$/,
|
||||||
loader: 'hot-self-accept-loader',
|
loader: 'hot-self-accept-loader',
|
||||||
include: [
|
include: [
|
||||||
|
@ -94,6 +83,19 @@ export default async function createCompiler (dir, { hotReload = false, dev = fa
|
||||||
]
|
]
|
||||||
}] : [])
|
}] : [])
|
||||||
.concat([{
|
.concat([{
|
||||||
|
test: /\.json$/,
|
||||||
|
loader: 'json-loader'
|
||||||
|
}, {
|
||||||
|
test: /\.(js|json)$/,
|
||||||
|
loader: 'emit-file-loader',
|
||||||
|
include: [dir, nextPagesDir],
|
||||||
|
exclude (str) {
|
||||||
|
return /node_modules/.test(str) && str.indexOf(nextPagesDir) !== 0
|
||||||
|
},
|
||||||
|
query: {
|
||||||
|
name: 'dist/[path][name].[ext]'
|
||||||
|
}
|
||||||
|
}, {
|
||||||
loader: 'babel',
|
loader: 'babel',
|
||||||
include: nextPagesDir,
|
include: nextPagesDir,
|
||||||
query: {
|
query: {
|
||||||
|
@ -180,9 +182,6 @@ export default async function createCompiler (dir, { hotReload = false, dev = fa
|
||||||
},
|
},
|
||||||
plugins,
|
plugins,
|
||||||
module: {
|
module: {
|
||||||
preLoaders: [
|
|
||||||
{ test: /\.json$/, loader: 'json-loader' }
|
|
||||||
],
|
|
||||||
loaders
|
loaders
|
||||||
},
|
},
|
||||||
customInterpolateName: function (url, name, opts) {
|
customInterpolateName: function (url, name, opts) {
|
||||||
|
|
Loading…
Reference in a new issue