Browse Source

feat: project basic skeleton created

yhhu 5 years ago
parent
commit
71e25f57eb
8 changed files with 4524 additions and 0 deletions
  1. 3 0
      .babelrc
  2. 16 0
      index.html
  3. 28 0
      package.json
  4. 1 0
      src/index.js
  5. 3 0
      webpack.config.js
  6. 51 0
      webpack/webpack.config.dev.js
  7. 54 0
      webpack/webpack.config.prod.js
  8. 4368 0
      yarn.lock

+ 3 - 0
.babelrc

@@ -0,0 +1,3 @@
+{
+  "presets": ["babel-preset-env"]
+}

+ 16 - 0
index.html

@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+	<meta charset="UTF-8">
+	<title><%= htmlWebpackPlugin.options.title %></title>
+	<% for (let css in htmlWebpackPlugin.files.css) { %>
+		<link href="<%=htmlWebpackPlugin.files.css[css] %>" rel="stylesheet">
+	<% } %>
+</head>
+<body>
+	<div id="container" class="container"></div>
+	<% for (let chunk in htmlWebpackPlugin.files.chunks) { %>
+		<script src="<%=htmlWebpackPlugin.files.chunks[chunk].entry %>"></script>
+	<% } %>
+</body>
+</html>

+ 28 - 0
package.json

@@ -0,0 +1,28 @@
+{
+  "name": "datepicker",
+  "version": "2.0.0",
+  "description": "datepicker",
+  "main": "src/index.js",
+  "scripts": {
+    "start:dev": "NODE_ENV=dev webpack-dev-server",
+    "build": "rm -rf ./dist && npx webpack"
+  },
+  "repository": "https://github.com/Rynxiao/datepicker.git",
+  "author": "ryn",
+  "license": "ISC",
+  "dependencies": {
+    "react": "^16.5.2"
+  },
+  "devDependencies": {
+    "babel-core": "^6.26.3",
+    "babel-loader": "7.1.5",
+    "babel-preset-env": "^1.7.0",
+    "css-loader": "^1.0.0",
+    "html-webpack-plugin": "^3.2.0",
+    "mini-css-extract-plugin": "^0.4.3",
+    "style-loader": "^0.23.0",
+    "webpack": "^4.19.1",
+    "webpack-cli": "^3.1.0",
+    "webpack-dev-server": "^3.1.8"
+  }
+}

+ 1 - 0
src/index.js

@@ -0,0 +1 @@
+alert(1)

+ 3 - 0
webpack.config.js

@@ -0,0 +1,3 @@
+var devConfig = require('./webpack/webpack.config.dev')
+var prodConfig = require('./webpack/webpack.config.prod')
+module.exports = process.env.NODE_ENV === 'dev' ? devConfig : prodConfig

+ 51 - 0
webpack/webpack.config.dev.js

@@ -0,0 +1,51 @@
+const path = require('path')
+const webpack = require('webpack')
+const HtmlWebpackPlugin = require('html-webpack-plugin')
+const projectPath = path.resolve(__dirname, '../')
+
+module.exports = {
+	mode: 'development',
+	entry: path.resolve(projectPath, 'src/index.js'),
+	output: {
+		path: path.resolve(__dirname, 'dist'),
+		filename: 'bundle.js'
+	},
+  module: {
+    rules: [
+      {
+        test: /\.js$/,
+        loader: 'babel-loader',
+        include: path.resolve(projectPath, 'src'),
+        exclude: path.resolve(projectPath, "node_modules"),
+     	},
+      {
+        test: /\.css$/,
+        use: [
+        	{ loader: "style-loader" },
+          {
+          	loader: "css-loader",
+          	options: {
+              modules: true,
+          		camelCase: true,
+          		localIdentName: '[name]__[local]--[hash:base64:5]'
+          	}
+          }
+        ]
+      },
+    ]
+  },
+  plugins: [
+    new webpack.HotModuleReplacementPlugin(),
+    new HtmlWebpackPlugin({
+      title: 'DatePicker',
+      filename: 'index.html',
+      template: path.resolve(projectPath, 'index.html'),
+      inject: false
+    })
+  ],
+  devServer: {
+    port: 8080,
+    contentBase: path.resolve(projectPath, 'build'),
+    hot: true
+  },
+}

+ 54 - 0
webpack/webpack.config.prod.js

@@ -0,0 +1,54 @@
+const path = require('path')
+const MiniCssExtractPlugin = require("mini-css-extract-plugin")
+const HtmlWebpackPlugin = require('html-webpack-plugin')
+const projectPath = path.resolve(__dirname, '../')
+
+module.exports = {
+	mode: 'production',
+	entry: './src/index.js',
+	output: {
+		path: path.resolve(__dirname, '../dist'),
+		filename: '[name]-bundle-[hash:8].js'
+	},
+  module: {
+    rules: [
+      {
+        test: /\.js$/,
+        loader: 'babel-loader',
+        include: path.resolve(projectPath, 'src'),
+        exclude: path.resolve(projectPath, "node_modules"),
+     	},
+      {
+        test: /\.css$/,
+        use: [
+          {
+            loader: MiniCssExtractPlugin.loader,
+            options: {
+              publicPath: '../build/styles'
+            }
+          },
+          { 
+          	loader: "css-loader",
+          	options: {
+          		modules: true,
+          		camelCase: true,
+          		localIdentName: '[name]__[local]--[hash:base64:5]'
+          	}
+          }
+        ]
+      }
+    ]
+  },
+  plugins: [
+    new MiniCssExtractPlugin({
+      filename: "[name].css",
+      chunkFilename: "[id].css"
+    }),
+    new HtmlWebpackPlugin({
+      title: 'CSS Modules Demo',
+      filename: 'index.html',
+      template: path.resolve(projectPath, 'index.html'),
+      inject: false
+    })
+  ],
+}

File diff suppressed because it is too large
+ 4368 - 0
yarn.lock