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

change build directories structure

This commit is contained in:
nkzawa 2016-10-17 12:55:09 +09:00
parent 3c88a3d7a8
commit fb6f5d4382
2 changed files with 8 additions and 8 deletions

View file

@ -11,12 +11,12 @@ export default async function createCompiler (dir, { hotReload = false } = {}) {
const entry = {} const entry = {}
const defaultEntries = hotReload ? ['webpack/hot/only-dev-server'] : [] const defaultEntries = hotReload ? ['webpack/hot/only-dev-server'] : []
for (const p of pages) { for (const p of pages) {
entry[join('_bundles', p)] = defaultEntries.concat(['./' + p]) entry[join('bundles', p)] = defaultEntries.concat(['./' + p])
} }
const errEntry = join('_bundles', 'pages', '_error.js') const errorEntry = join('bundles', 'pages', '_error.js')
const defaultErrorPath = resolve(__dirname, '..', '..', 'pages', '_error.js') const defaultErrorPath = resolve(__dirname, '..', '..', 'pages', '_error.js')
if (!entry[errEntry]) entry[errEntry] = defaultErrorPath if (!entry[errorEntry]) entry[errorEntry] = defaultErrorPath
const nodeModulesDir = resolve(__dirname, '..', '..', '..', 'node_modules') const nodeModulesDir = resolve(__dirname, '..', '..', '..', 'node_modules')
@ -42,7 +42,7 @@ export default async function createCompiler (dir, { hotReload = false } = {}) {
], ],
exclude: /node_modules/, exclude: /node_modules/,
query: { query: {
name: '[path][name].[ext]' name: 'dist/[path][name].[ext]'
} }
}, { }, {
test: /\.js$/, test: /\.js$/,
@ -118,7 +118,7 @@ export default async function createCompiler (dir, { hotReload = false } = {}) {
}, },
customInterpolateName: function (url, name, opts) { customInterpolateName: function (url, name, opts) {
if (defaultErrorPath === this.resourcePath) { if (defaultErrorPath === this.resourcePath) {
return 'pages/_error.js' return 'dist/pages/_error.js'
} }
return url return url
} }

View file

@ -16,11 +16,11 @@ export async function render (url, ctx = {}, {
staticMarkup = false staticMarkup = false
} = {}) { } = {}) {
const path = getPath(url) const path = getPath(url)
const mod = await requireModule(resolve(dir, '.next', 'pages', path)) const mod = await requireModule(resolve(dir, '.next', 'dist', 'pages', path))
const Component = mod.default || mod const Component = mod.default || mod
const props = await (Component.getInitialProps ? Component.getInitialProps(ctx) : {}) const props = await (Component.getInitialProps ? Component.getInitialProps(ctx) : {})
const component = await read(resolve(dir, '.next', '_bundles', 'pages', path)) const component = await read(resolve(dir, '.next', 'bundles', 'pages', path))
const { html, css } = StyleSheetServer.renderStatic(() => { const { html, css } = StyleSheetServer.renderStatic(() => {
const app = createElement(App, { const app = createElement(App, {
@ -53,7 +53,7 @@ export async function render (url, ctx = {}, {
export async function renderJSON (url, { dir = process.cwd() } = {}) { export async function renderJSON (url, { dir = process.cwd() } = {}) {
const path = getPath(url) const path = getPath(url)
const component = await read(resolve(dir, '.next', '_bundles', 'pages', path)) const component = await read(resolve(dir, '.next', 'bundles', 'pages', path))
return { component } return { component }
} }