chore(fs.dev): Webpack aliases to load local code from source
These changes force webpack to load the local pacakges (like patterns and so on) from source, rather than from a compiled bundle. This means that the lab site will reload whenever one makes changes to pattern code.
This commit is contained in:
parent
2169994f0a
commit
2ea353a475
7 changed files with 35 additions and 10 deletions
|
@ -1,7 +1,17 @@
|
|||
import path from 'path'
|
||||
import remarkGfm from 'remark-gfm'
|
||||
import { patterns } from '../../../config/packages.mjs'
|
||||
|
||||
const config = (site, remarkPlugins=[]) => ({
|
||||
/*
|
||||
* This mehthod will return the NextJS configuration
|
||||
* Parameters:
|
||||
*
|
||||
* site: one of 'dev', 'org', or 'lab'
|
||||
* remarkPlugins: Array of remark plugins to load
|
||||
* srcPkgs: Array of folders in the monorepo/packages that should be aliased
|
||||
* so they are loaded from source, rather than from a compiled bundle
|
||||
*/
|
||||
const config = (site, remarkPlugins=[], srcPkgs=[]) => ({
|
||||
experimental: {
|
||||
externalDir: true,
|
||||
esmExternals: true,
|
||||
|
@ -48,6 +58,10 @@ const config = (site, remarkPlugins=[]) => ({
|
|||
config.resolve.alias.site = path.resolve(`../freesewing.${site}/`)
|
||||
config.resolve.alias.markdown = path.resolve(`../../markdown/${site}/`)
|
||||
config.resolve.alias.pkgs = path.resolve(`../`)
|
||||
// This forces webpack to load the code from source, rather than compiled bundle
|
||||
for (const pkg of srcPkgs) {
|
||||
config.resolve.alias[`@freesewing/${pkg}$`] = path.resolve(`../${pkg}/src/index.js`)
|
||||
}
|
||||
|
||||
return config
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue