From fb6f5d43826500643ea3150e3b0f10f320315568 Mon Sep 17 00:00:00 2001 From: nkzawa Date: Mon, 17 Oct 2016 12:55:09 +0900 Subject: [PATCH] change build directories structure --- server/build/webpack.js | 10 +++++----- server/render.js | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/server/build/webpack.js b/server/build/webpack.js index 8b15b8d0..d2520cea 100644 --- a/server/build/webpack.js +++ b/server/build/webpack.js @@ -11,12 +11,12 @@ export default async function createCompiler (dir, { hotReload = false } = {}) { const entry = {} const defaultEntries = hotReload ? ['webpack/hot/only-dev-server'] : [] 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') - if (!entry[errEntry]) entry[errEntry] = defaultErrorPath + if (!entry[errorEntry]) entry[errorEntry] = defaultErrorPath const nodeModulesDir = resolve(__dirname, '..', '..', '..', 'node_modules') @@ -42,7 +42,7 @@ export default async function createCompiler (dir, { hotReload = false } = {}) { ], exclude: /node_modules/, query: { - name: '[path][name].[ext]' + name: 'dist/[path][name].[ext]' } }, { test: /\.js$/, @@ -118,7 +118,7 @@ export default async function createCompiler (dir, { hotReload = false } = {}) { }, customInterpolateName: function (url, name, opts) { if (defaultErrorPath === this.resourcePath) { - return 'pages/_error.js' + return 'dist/pages/_error.js' } return url } diff --git a/server/render.js b/server/render.js index 7e14fe7b..3ebf7703 100644 --- a/server/render.js +++ b/server/render.js @@ -16,11 +16,11 @@ export async function render (url, ctx = {}, { staticMarkup = false } = {}) { 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 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 app = createElement(App, { @@ -53,7 +53,7 @@ export async function render (url, ctx = {}, { export async function renderJSON (url, { dir = process.cwd() } = {}) { 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 } }