Skip to content

Commit

Permalink
chore: webpackReactJsCli构建
Browse files Browse the repository at this point in the history
  • Loading branch information
wangshan committed Mar 14, 2022
1 parent f1e6860 commit beab798
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
11 changes: 10 additions & 1 deletion config/webpack.common.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* @LastEditTime: 2022-03-15 01:17:39
* @LastEditTime: 2022-03-15 01:28:15
* @Description: 公共配置文件
* @Date: 2022-03-15 00:33:46
* @Author: wangshan
Expand Down Expand Up @@ -88,6 +88,15 @@ module.exports = function (options) {
},
],
},
resolve: {
modules: [paths.appNodeModules],
extensions: [".js", ".jsx", ".css"],
alias: {
moment$: "moment/moment.js",
"@src": paths.appSrc,
"@public": paths.appPublic,
},
},
devServer: {},
plugins: [
new HtmlWebpackPlugin({
Expand Down
10 changes: 3 additions & 7 deletions config/webpack.dev.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
/*
* @LastEditTime: 2022-03-15 01:10:15
* @LastEditTime: 2022-03-15 01:28:07
* @Description: 开发环境配置
* @Date: 2022-03-15 00:33:30
* @Author: wangshan
* @LastEditors: wangshan
*/

module.exports = require("./webpack.common")({
mode: "development",
modules: [paths.appNodeModules],
extensions: [".js", ".jsx", ".css"],
alias: {
"@src": paths.appSrc,
"@public": paths.appPublic,
},

plugins: [],
stats: "errors-only", //只在发生错误或有新的编译时输出
});
11 changes: 8 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* @LastEditTime: 2022-03-15 01:20:56
* @LastEditTime: 2022-03-15 01:31:46
* @Description: 应用打包入口文件
* @Date: 2022-03-15 00:37:34
* @Author: wangshan
Expand All @@ -8,10 +8,15 @@
import React from "react";
import ReactDOM from "react-dom";
import "@src/style.scss";
import npm from "@public/assets/imgs/npm.png";
import npm from "@public/images/pic.jpeg";

const App = () => {
return <div> App入口 </div>;
return (
<div>
<h1>Webpack CLI</h1>
<img src={npm}></img>
</div>
);
};

ReactDOM.render(<App />, document.querySelector("#root"));

0 comments on commit beab798

Please sign in to comment.