Skip to content

Commit

Permalink
Merge pull request #19 from knowankit/fix/source-map-with-other-issues
Browse files Browse the repository at this point in the history
Fix source map, webpack build, react import
  • Loading branch information
knowankit authored Oct 10, 2021
2 parents ed314ae + eb66b04 commit 059fcca
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ Congratlations 🎉, you have published your package
## Libraries bootstrapped from this CLI - build-react-npm

* [React bubble effect button](https://github.com/knowankit/react-bubbly-effect-button)
* [Particle effect on text](https://github.com/knowankit/particle-text-effect)

## License

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "build-react-npm",
"version": "0.3.0",
"version": "0.3.3",
"description": "Create your react npm library and publish it in no time",
"main": "src/index.js",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions templates/javascript/src/example-component.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import styles from './index.module.css';
import PropTypes from 'prop-types';
import React from 'react';

const ExampleComponent = ({ text }) => {
return <h1 className={styles.test}>{text}</h1>;
Expand Down
17 changes: 16 additions & 1 deletion templates/javascript/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = env => {
const config = {
mode: env.development ? 'development' : 'production',
devtool: 'inline-source-map',
entry: env.development
? `${path.resolve(__dirname, './src/index.js')}`
: `${path.resolve(__dirname, './src/example-component.js')}`,
Expand Down Expand Up @@ -46,7 +47,21 @@ module.exports = env => {
resolve: {
extensions: ['.js', '.jsx']
},
plugins: [new CleanWebpackPlugin()]
plugins: [new CleanWebpackPlugin()],
externals: {
react: {
root: 'React',
commonjs2: 'react',
commonjs: 'react',
amd: 'react'
},
'react-dom': {
root: 'ReactDOM',
commonjs2: 'react-dom',
commonjs: 'react-dom',
amd: 'react-dom'
}
}
};

if (env.development) {
Expand Down
19 changes: 17 additions & 2 deletions templates/typescript/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');

module.exports = (env) => {
module.exports = env => {
const config = {
mode: env.development ? 'development' : 'production',
devtool: 'inline-source-map',
entry: {
main: env.development
? `${path.resolve(__dirname, './src/index.tsx')}`
Expand Down Expand Up @@ -43,7 +44,21 @@ module.exports = (env) => {
resolve: {
extensions: ['.tsx', '.ts', '.js']
},
plugins: [new CleanWebpackPlugin()]
plugins: [new CleanWebpackPlugin()],
externals: {
react: {
root: 'React',
commonjs2: 'react',
commonjs: 'react',
amd: 'react'
},
'react-dom': {
root: 'ReactDOM',
commonjs2: 'react-dom',
commonjs: 'react-dom',
amd: 'react-dom'
}
}
};

if (env.development) {
Expand Down

0 comments on commit 059fcca

Please sign in to comment.