Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* --------------
- * -- Expected file system -- *
- - package.json
- - package-lock.json (generated by npm)
- - src/
- - page.js
- - .babelrc
- - webpack.config.js
- - dist/ (this and contents generated by webpack)
- - page.js
- * -- npm scripts -- *
- npm init
- npm i react react-dom
- npm i @babel/preset-env @babel/preset-react babel-loader -D
- /* ----------- */
- // package.json
- ...
- "scripts": {
- "start": "webpack",
- "dev": "webpack --watch --progress",
- },
- ...
- /* ----------- */
- // webpack.config.js
- const path = require("path");
- module.exports = {
- entry: {
- ["page"]: "./src/page.js",
- },
- module: {
- rules: [
- {
- test: /\.(js|jsx)$/,
- exclude: /node_modules/,
- use: ["babel-loader"],
- },
- ],
- },
- resolve: {
- extensions: ["*", ".js", ".jsx"],
- },
- mode: "production",
- output: {
- path: path.resolve(__dirname, "dist"),
- filename: "[name].js",
- library: "[name]",
- libraryTarget: "umd",
- globalObject: "this",
- umdNamedDefine: true,
- clean: true,
- },
- };
- /* ----------- */
- // .babelrc
- {
- "presets": ["@babel/preset-env", "@babel/preset-react"]
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement