1
0
Fork 0

feat(cfp): Updated for React 17 / CRA 4 / Webpack 5

This commit is contained in:
Joost De Cock 2021-05-22 17:58:52 +02:00
parent e3358a03ef
commit 380fa33c6a
7 changed files with 34 additions and 19 deletions

View file

@ -121,7 +121,7 @@ create-freesewing-pattern:
'make-dir': '^3.1.0' 'make-dir': '^3.1.0'
'normalize-path': '^3.0.0' 'normalize-path': '^3.0.0'
'ora': '^5.4.0' 'ora': '^5.4.0'
'p-each-series': '^3.0.0' 'p-each-series': '^2.2.0'
'parse-git-config': '^3.0.0' 'parse-git-config': '^3.0.0'
'validate-npm-package-name': '^3.0.0' 'validate-npm-package-name': '^3.0.0'
'which': '^2.0.2' 'which': '^2.0.2'

View file

@ -40,9 +40,9 @@ module.exports = async () => {
.option('-m, --manager <npm|yarn>', 'package manager to use', /^(npm|yarn)$/, defaults.manager) .option('-m, --manager <npm|yarn>', 'package manager to use', /^(npm|yarn)$/, defaults.manager)
.option('-v, --skip-version-check', 'proceed even with Node < v10') .option('-v, --skip-version-check', 'proceed even with Node < v10')
.option( .option(
'-t, --template <default|custom>', '-t, --template <freesewing|custom>',
'package template to use', 'package template to use',
/^(default|custom)$/, /^(freesewing|custom)$/,
defaults.template defaults.template
) )
.option('-p, --template-path <string>', 'custom package template path') .option('-p, --template-path <string>', 'custom package template path')
@ -84,22 +84,18 @@ module.exports = async () => {
${strings[params.language]['cfp.runTheseCommands']}: ${strings[params.language]['cfp.runTheseCommands']}:
- ${strings[params.language]['cfp.startRollup']}
👉 ${chalk.cyan(`cd ${params.shortName} && ${params.manager} start`)}
- ${strings[params.language]['cfp.startWebpack']}
👉 ${chalk.cyan(`cd ${path.join(params.shortName, 'example')} && ${params.manager} start`)} 👉 ${chalk.cyan(`cd ${path.join(params.shortName, 'example')} && ${params.manager} start`)}
${strings[params.language]['cfp.startWebpack']}
${strings[params.language]['cfp.devDocsAvailableAt']} ${strings[params.language]['cfp.devDocsAvailableAt']}
${chalk.bold('https://freesewing.dev/')} ${chalk.bold('https://freesewing.dev/')}
${strings[params.language]['cfp.talkToUs']} ${strings[params.language]['cfp.talkToUs']}
${chalk.bold('https://chat.freesewing.org/')} ${chalk.bold('https://discord.freesewing.org/')}
`) `
)
return dest return dest
} }

View file

@ -59,6 +59,16 @@ module.exports = async (info) => {
await promise await promise
} }
// Symlink is required since webback 5 / CRA 4
fs.symlinkSync(
path.join(dest),
path.join(dest, 'example', 'src', 'pattern'),
'junction',
(err) => {
if (err) console.log('Unable to create symlink to pattern folder:', err)
}
)
return dest return dest
} }

View file

@ -15,7 +15,7 @@ module.exports = async () => {
repo: info => `${info.author}/${info.name}`, repo: info => `${info.author}/${info.name}`,
license: config.get("license", "MIT"), license: config.get("license", "MIT"),
manager: config.get("manager", "npm"), manager: config.get("manager", "npm"),
template: config.get("template", "default") template: config.get("template", "freesewing")
}; };
try { try {

View file

@ -134,9 +134,9 @@ module.exports = async opts => {
config.set('author', info.author) config.set('author', info.author)
config.set('manager', info.manager) config.set('manager', info.manager)
config.set('template', 'default') config.set('template', 'freesewing')
config.set('license', 'MIT') config.set('license', 'MIT')
info.template = 'default' info.template = 'freesewing'
return { return {
...info, ...info,

View file

@ -2,8 +2,17 @@ import React from 'react'
import freesewing from '@freesewing/core' import freesewing from '@freesewing/core'
import Workbench from '@freesewing/components/Workbench' import Workbench from '@freesewing/components/Workbench'
import '@freesewing/css-theme' import '@freesewing/css-theme'
import Pattern from './pattern/src/index.js'
/*
* The following symlink is required to make this import work:
* `root_folder/example/src/pattern => `../../`
*
* Without it, we can't import the pattern as a local file
* since create-react-app does not allow imports outside ./src
* If it's imported as a dependency, webpack will cache the
* build and there will be no hot-relaoding of changes
*/
import Pattern from 'pattern'
const App = (props) => { const App = (props) => {
// You can use this to add transations // You can use this to add transations

View file

@ -5,7 +5,7 @@ import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json' import json from '@rollup/plugin-json'
import { terser } from 'rollup-plugin-terser' import { terser } from 'rollup-plugin-terser'
import peerDepsExternal from 'rollup-plugin-peer-deps-external' import peerDepsExternal from 'rollup-plugin-peer-deps-external'
import postcss from 'rollup-plugin-postcss' //import postcss from 'rollup-plugin-postcss'
import { name, version, description, author, license } from './package.json' import { name, version, description, author, license } from './package.json'
import pkg from './package.json' import pkg from './package.json'
@ -28,9 +28,9 @@ export default {
], ],
plugins: [ plugins: [
peerDepsExternal(), peerDepsExternal(),
postcss({ //postcss({
modules: true // modules: true
}), //}),
url({ exclude: ['**/*.svg'] }), url({ exclude: ['**/*.svg'] }),
babel({ babel({
exclude: 'node_modules/**' exclude: 'node_modules/**'