How to pass .env file variables to webpack config?

You can use dotenv package for this purpose. npm install dotenv –save After installing the package, add this in the top of your config: const webpack = require(‘webpack’); // only add this if you don’t have yet // replace accordingly ‘./.env’ with the path of your .env file require(‘dotenv’).config({ path: ‘./.env’ }); then in plugins … Read more

One project with multiple package.json files

OK, so after some more research I stumbled upon Lerna which mostly allows me to do what I wanted (from what I’ve seen so far). It requires specific project tree setup, like this: project_root/ node_modules/ packages/ components/ // Components shared between projects components/ MyComponent.jsx index.jsx legacy/ output/ build.js // React 0.14 build node_modules/ package.json // … Read more

Webpack bundles my files in the wrong order (CommonsChunkPlugin)

Success! webpack.config.js module.exports = { entry: { app: ‘./app.jsx’, vendor: [ “script-loader!uglify-loader!jquery”, “script-loader!uglify-loader!tether”, “script-loader!uglify-loader!bootstrap”, “script-loader!uglify-loader!wowjs”, ] }, output: { path: __dirname + ‘/dist’, filename: ‘bundle.js’, }, plugins: [ new webpack.optimize.CommonsChunkPlugin({ name: ‘vendor’, filename: “https://stackoverflow.com/questions/42988320/vendor.bundle.js” }), new webpack.optimize.UglifyJsPlugin(), ], }; What magic is happening here? Webpack creates vendor.bundle.js by minifying & bundling my vendor files which … Read more

Typescript react – Could not find a declaration file for module ”react-materialize’. ‘path/to/module-name.js’ implicitly has an any type

I had a similar error but for me it was react-router. Solved it by installing types for it. npm install –save @types/react-router Error: (6,30): error TS7016: Could not find a declaration file for module ‘react-router’. ‘\node_modules\react-router\index.js’ implicitly has an ‘any’ type. If you would like to disable it site wide you can instead edit tsconfig.json … Read more