Closed bdwenxi closed 5 years ago
macos
const defaults = {compilerOptions: {module: 'commonjs'}, exclude: ['node_modules', 'dist']}; const override = { compilerOptions: {module: 'es2015'}, exclude: ['node_modules', 'dist', 'scripts', 'examples', 'gulpfile.ts', 'common'] }; let rollupConfigs: RollupOptions = { input: utils.pathResolve(`components/${componentName}/index.tsx`), output: { file: utils.pathResolve(`dist/${componentName}/index.js`), name: componentName === 'index.tsx' ? 'Duui' : pascalCase(componentName), format: 'cjs', globals: { react: 'React', 'react-dom': 'ReactDOM', 'classnames': 'classnames', 'shallowequal': 'shallowequal', } }, external: [ 'react', 'react-dom', 'better-scroll', 'classnames', 'rc-animate', 'shallowequal', ...components .filter(component => component !== 'index,tsx') .map(component => `@baidu/duui/${component}`) ], // @ts-ignore plugins: [ svgr(), external(), nodeResovle(), typescript({ verbosity: -1, tsconfigDefaults: defaults, tsconfig: 'tsconfig.json', tsconfigOverride: override, objectHashIgnoreUnknownHack: true, rollupCommonJSResolveHack: true, typescript: require('typescript') }), commonjs({ include: ['node_modules/**'], namedExports: { 'node_modules/react/index.js': [ 'Component', 'PureComponent', 'Fragment', 'Children', 'createElement', 'createRef', 'cloneElement' ], 'node_modules/react-dom/index.js': ['render', 'createPortal'] } }) ] };
{ "compilerOptions": { "baseUrl": "./", "target": "es5", "module": "commonjs", "composite": true, "declaration": true, "removeComments": true, "downlevelIteration": true, "noImplicitThis": true, "paths": { "@baidu/duui/*": ["./components/*/index.tsx"], "duui": ["components/index.tsx"] }, "strictNullChecks": true, "moduleResolution": "node", "esModuleInterop": true, "experimentalDecorators": true, "jsx": "react", "noUnusedParameters": true, "noUnusedLocals": true, "importHelpers": true, "allowSyntheticDefaultImports": true, "lib": ["es2015", "es2016", "es2017", "dom"] }, "exclude": ["node_modules", "dist", "scripts"] }
"devDependencies": { "@babel/core": "^7.6.4", "@babel/plugin-proposal-class-properties": "^7.5.5", "@babel/plugin-proposal-decorators": "^7.6.0", "@babel/plugin-proposal-export-default-from": "^7.5.2", "@babel/plugin-proposal-object-rest-spread": "^7.6.2", "@babel/plugin-syntax-dynamic-import": "^7.2.0", "@babel/plugin-transform-runtime": "^7.6.2", "@babel/preset-env": "^7.6.3", "@babel/preset-react": "^7.6.3", "@babel/preset-typescript": "^7.6.0", "@babel/register": "^7.6.2", "@babel/runtime": "^7.6.3", "@svgr/rollup": "^4.3.3", "@types/autoprefixer": "^9.6.1", "@types/babel__core": "^7.1.3", "@types/better-scroll": "^1.12.1", "@types/body-parser": "^1.17.1", "@types/classnames": "^2.2.9", "@types/co": "^4.6.2", "@types/cssnano": "^4.0.0", "@types/express": "^4.17.1", "@types/fs-extra": "^8.0.1", "@types/glob": "^7.1.1", "@types/gulp": "^4.0.6", "@types/gulp-postcss": "^8.0.0", "@types/gulp-rename": "^0.0.33", "@types/gulp-sass": "^4.0.0", "@types/handlebars-helpers": "^0.5.2", "@types/inquirer": "^6.5.0", "@types/mini-css-extract-plugin": "^0.8.0", "@types/node": "^12.12.3", "@types/node-sass": "^4.11.0", "@types/optimize-css-assets-webpack-plugin": "^5.0.1", "@types/react": "^16.9.11", "@types/react-dom": "^16.9.3", "@types/rimraf": "^2.0.3", "@types/rollup-plugin-peer-deps-external": "^2.2.0", "@types/rollup-plugin-url": "^2.2.0", "@types/shallowequal": "^1.1.1", "@types/shelljs": "^0.8.5", "@types/svgr__rollup": "^4.3.0", "@types/webpack": "^4.39.5", "@types/webpack-dev-middleware": "^2.0.3", "@types/webpack-hot-middleware": "^2.16.5", "@types/webpack-merge": "^4.1.5", "autoprefixer": "^9.7.0", "babel-loader": "^8.0.6", "better-scroll": "^1.15.2", "body-parser": "^1.19.0", "chalk": "^3.0.0", "classnames": "^2.2.6", "co": "^4.6.0", "css-loader": "^3.2.0", "cssnano": "^4.1.10", "del": "^5.1.0", "execa": "^3.2.0", "express": "^4.17.1", "fs-extra": "^8.1.0", "glob": "^7.1.5", "gulp": "^4.0.2", "gulp-clean-css": "^4.2.0", "gulp-cli": "^2.2.0", "gulp-postcss": "^8.0.0", "gulp-rename": "^1.4.0", "gulp-replace-name": "^1.0.1", "gulp-sass": "^4.0.2", "handlebars": "^4.5.1", "handlebars-helpers": "^0.10.0", "inquirer": "^7.0.0", "mini-css-extract-plugin": "^0.8.0", "node-sass": "^4.13.0", "opn": "^6.0.0", "optimize-css-assets-webpack-plugin": "^5.0.3", "postcss-loader": "^3.0.0", "rc-animate": "^2.10.2", "react": "^16.12.0", "react-dom": "^16.12.0", "resolve-url-loader": "^3.1.0", "rimraf": "^3.0.0", "rollup": "^1.27.0", "rollup-plugin-babel": "^4.3.3", "rollup-plugin-cleanup": "^3.1.1", "rollup-plugin-commonjs": "^10.1.0", "rollup-plugin-node-resolve": "^5.2.0", "rollup-plugin-peer-deps-external": "^2.2.0", "rollup-plugin-prettier": "^0.6.0", "rollup-plugin-typescript2": "^0.25.2", "rollup-plugin-url": "^3.0.0", "sass-loader": "^8.0.0", "shallowequal": "^1.1.0", "shelljs": "^0.8.3", "style-loader": "^1.0.0", "ts-node": "^8.4.1", "typescript": "^3.6.4", "webpack": "^4.41.2", "webpack-dev-middleware": "^3.7.2", "webpack-hot-middleware": "^2.25.0", "webpack-merge": "^4.2.2" }, "peerDependencies": { "better-scroll": "^1.15.2", "classnames": "^2.2.6", "rc-animate": "^2.10.1", "react": ">=16.3.0", "react-dom": ">=16.3.0", "shallowequal": "^1.1.0" }
How did you solve this? I'm using the same plugins and facing the same error
Duplicate of #160
Could not resolve '../../icons/toast/success.svg' from components/toast/index.tsx
Environment
macos
Versions
rollup.config.js
tsconfig.json
package.json