5. Modular JavaScript
Activity 6: Creating a Lightbulb with a Flash Mode
Solution:
- Install the babel-cliandbabelpreset as developer dependencies:npm install --save-dev webpack webpack-cli @babel/core @babel/cli @babel/preset-env 
- Add a file called .babelrcto the root directory. In it, we will tell Babel to use the preset settings:{ Â Â "presets": ["@babel/preset-env"] }
- Add a webpack configuration file at webpack.config.jsin the root directory:const path = require("path"); module.exports = { Â Â mode: 'development', Â Â entry: "./build/js/viewer.js", Â Â output: { Â Â Â Â path: path.resolve(__dirname, "build"), Â Â Â Â filename: "bundle.js" Â Â } };
- Create a new file called js/flashingLight.js. This should start as a blank ES6 component that extendsLight. In the constructor, we will includestate,brightness, andflashMode...
 
                                             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
     
         
                 
                 
                 
                 
                 
                 
                 
                 
                 
                 
                 
                 
                 
                 
                