From 8811a334f40e9ae009014125e53c8bec8899efc5 Mon Sep 17 00:00:00 2001 From: Arunoda Susiripala Date: Wed, 11 Jan 2017 17:57:33 -0800 Subject: [PATCH] Remove default next pages compilation from the main babel-loader. (#731) * Remove default next pages compilation from the main babel-loader. This will fix the issue when the user ignore node_modules via our .babelrc option. * Change babel-loaders 'query' to 'options'. That's what's supported/recommended in webpack 2 --- server/build/babel/preset.js | 3 ++- server/build/webpack.js | 21 +++++++-------------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/server/build/babel/preset.js b/server/build/babel/preset.js index 7b57a722..37817b78 100644 --- a/server/build/babel/preset.js +++ b/server/build/babel/preset.js @@ -27,7 +27,8 @@ module.exports = { 'next/head': require.resolve('../../../lib/head'), 'next/document': require.resolve('../../../server/document'), 'next/router': require.resolve('../../../lib/router'), - 'styled-jsx/style': require.resolve('styled-jsx/style') + 'styled-jsx/style': require.resolve('styled-jsx/style'), + 'ansi-html': require.resolve('ansi-html') } } ] diff --git a/server/build/webpack.js b/server/build/webpack.js index f3fc9805..c6907712 100644 --- a/server/build/webpack.js +++ b/server/build/webpack.js @@ -143,30 +143,23 @@ export default async function createCompiler (dir, { dev = false, quiet = false }, { loader: 'babel-loader', include: nextPagesDir, + exclude (str) { + return /node_modules/.test(str) && str.indexOf(nextPagesDir) !== 0 + }, options: { babelrc: false, cacheDirectory: true, sourceMaps: dev ? 'both' : false, - plugins: [ - [ - require.resolve('babel-plugin-module-resolver'), - { - alias: { - 'ansi-html': require.resolve('ansi-html'), - 'styled-jsx/style': require.resolve('styled-jsx/style') - } - } - ] - ] + presets: [require.resolve('./babel/preset')] } }, { test: /\.js(\?[^?]*)?$/, loader: 'babel-loader', - include: [dir, nextPagesDir], + include: [dir], exclude (str) { - return /node_modules/.test(str) && str.indexOf(nextPagesDir) !== 0 + return /node_modules/.test(str) }, - query: mainBabelOptions + options: mainBabelOptions }]) let webpackConfig = {