message: add webpack resolve aliases to src in dev mode
diff: +const {join} = require('path')
  const withPlugins = require('next-compose-plugins')
  const mdx = require('@zeit/next-mdx')
  @@ -12,7 +13,33 @@ module.exports = withPlugins([
  assetPrefix: process.env.NOW_URL,
  pageExtensions: ['js', 'jsx', 'md', 'mdx'],
  - webpack(config) {
  + webpack(config, {dev}) {
  + if (dev) {
  + /*
  + * In development mode, we want to alias the project-root
  + * imports to the source files so that this:
  + *
  + * ```js
  + * import {Box} from '..'
  + * ```
  + *
  + * becomes:
  + *
  + * ```js
  + * import {Box} from '../src'
  + * ```
  + *
  + * Note: the '$' at the end of these tells webpack to match
  + * the end of the import path. Without it, the first alias
  + * applies to *every* import because the resolved path for
  + * every one begins with `__dirname`.
  + */
  + config.resolve.alias = {
  + [__dirname + '$']: join(__dirname, 'src/index.js'),
  + [join(__dirname, 'css$')]: join(__dirname, 'src/css.js')
  + }
  + }
  +
  const {optimization} = config
  if (optimization && Array.isArray(optimization.minimizer)) {
  const terserPlugin = optimization.minimizer[0]
  