Last active
October 22, 2020 02:04
-
-
Save BrianJenney/668b754970d87c31a1a57b3f0962c56d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
LoginReducer, | |
CartsReducer | |
} from 'shared-state/lib/Reducers'; | |
import { appSpecificReducer } from './localReducer' | |
const rootReducer = combineReducers({ | |
appSpecificReducer, | |
LoginReducer, | |
CartsReducer | |
}); | |
const store = createStore( | |
rootReducer, | |
composeEnhancers(applyMiddleware(reduxThunk, reduxStoreEvents)) | |
); | |
export default store; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export { default as CartsReducer } from './Cart/reducer.js'; | |
export { default as LoginReducer } from './Login/reducer.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
const fs = require('fs'); | |
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; | |
const TerserPlugin = require('terser-webpack-plugin'); | |
const entry = { | |
Reducers: ['./modules'] | |
}; | |
fs.readdirSync('./modules').forEach((folder) => { | |
if (folder.toString() !== 'index.js') { | |
fs.readdirSync(`./modules/${folder}`).forEach((file) => { | |
const fileToString = file.toString().split('.'); | |
if (fileToString.includes('actions') && !file.includes('test.js')) { | |
entry[`${fileToString[0]}Actions`] = [`./modules/${folder}/${file}`]; | |
} | |
}); | |
} | |
}); | |
const plugins = []; | |
const externals = { | |
redux: 'redux', | |
lodash: 'lodash', | |
}; | |
if (process.env.PROFILER === '1') { | |
plugins.push(new BundleAnalyzerPlugin()); | |
} | |
module.exports = { | |
module: { | |
rules: [ | |
{ | |
test: /\.m?js$/, | |
exclude: /(node_modules)/, | |
use: { | |
loader: 'babel-loader', | |
options: { | |
presets: ['@babel/preset-env'] | |
} | |
} | |
} | |
] | |
}, | |
optimization: { | |
minimizer: [ | |
new TerserPlugin({ | |
terserOptions: { | |
keep_fnames: true | |
} | |
}) | |
] | |
}, | |
context: __dirname, | |
entry, | |
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development', | |
plugins, | |
output: { | |
path: path.join(__dirname, 'lib'), | |
chunkFilename: '[name].[chunkhash].js', | |
filename: '[name].js', | |
libraryTarget: 'umd', | |
library: 'shared-state' | |
}, | |
externals | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment