Skip to content

Commit cbf2b25

Browse files
Create webpack.config.jsgg
1 parent 0e63b41 commit cbf2b25

File tree

1 file changed

+115
-0
lines changed

1 file changed

+115
-0
lines changed
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
// const path = require("path");
2+
// // import path from "path";
3+
// // import webpack from "webpack";
4+
// const webpack = require("webpack");
5+
// // import { WDS_PORT } from "./src/shared/config";
6+
// const WDS_PORT = require("./src/shared/config");
7+
// // import { isProd } from "./src/shared/util";
8+
// const isProd = require(" ./src/shared/util");
9+
10+
// module.exports = {
11+
// entry: {
12+
// main: ["react-hot-loader/patch", "./src/client"]
13+
// },
14+
// output: {
15+
// filename: "bundle.js",
16+
// path: path.resolve(__dirname, "dist/")
17+
// // publicPath: isProd ? "/static/" : `http://localhost:${WDS_PORT}/dist/`
18+
// },
19+
// module: {
20+
// rules: [
21+
// {
22+
// test: /\.(js|jsx)$/,
23+
// use: [(loader: "@babel/loader")],
24+
// exclude: /node_modules/
25+
// }
26+
// ]
27+
// },
28+
// devtool: isProd ? false : "source-map",
29+
// resolve: {
30+
// extensions: [".js", ".jsx"]
31+
// },
32+
// devServer: {
33+
// port: WDS_PORT,
34+
// hot: true,
35+
// headers: {
36+
// "Access-Control-Allow-Origin": "*"
37+
// }
38+
// },
39+
// plugins: [
40+
// new webpack.optimize.OccurrenceOrderPlugin(),
41+
// new webpack.HotModuleReplacementPlugin(),
42+
// new webpack.NamedModulesPlugin(),
43+
// new webpack.NoEmitOnErrorsPlugin()
44+
// ]
45+
// };
46+
const path = require("path");
47+
const webpack = require("webpack");
48+
const HTMLWebpackPlugin = require("html-webpack-plugin");
49+
module.exports = {
50+
// this is relative path. iw we do not specify default location is:./src/main.js
51+
entry: {
52+
main: [
53+
"@babel/polyfill",
54+
"@babel/runtime/regenerator",
55+
"react-hot-loader/patch",
56+
"./src/main.js"
57+
]
58+
},
59+
mode: "development",
60+
output: {
61+
filename: "[name]-output.js",
62+
path: path.resolve(__dirname, "../dist"),
63+
publicPath: "/"
64+
},
65+
devServer: {
66+
contentBase: "dist",
67+
overlay: true,
68+
hot: true,
69+
stats: { colors: true }
70+
},
71+
72+
devtool: "source-map",
73+
module: {
74+
rules: [
75+
{
76+
test: /\.css$/,
77+
use: [
78+
{ loader: "style-loader" },
79+
{ loader: "css-loader", options: { sourceMap: true } }
80+
]
81+
},
82+
{
83+
test: /\.js$/,
84+
use: [{ loader: "babel-loader" }],
85+
exclude: /node_modules/
86+
},
87+
{
88+
test: /\.s?css$/,
89+
use: ["style-loader", "css-loader", "postcss-loader", "sass-loader"]
90+
},
91+
{
92+
test: /\.html$/,
93+
use: [
94+
{
95+
loader: "html-loader",
96+
options: { attrs: ["img:src", "link:href"] }
97+
}
98+
]
99+
},
100+
{
101+
test: /\.(jpg|gif|png)$/,
102+
use: [
103+
{
104+
loader: "file-loader",
105+
options: { name: "images/[name].[ext]" }
106+
}
107+
]
108+
}
109+
]
110+
},
111+
plugins: [
112+
new webpack.HotModuleReplacementPlugin(),
113+
new HTMLWebpackPlugin({ template: "./src/index.html" })
114+
]
115+
};

0 commit comments

Comments
 (0)