├── .gitignore
├── dist
├── static
│ └── .gitkeep
├── precache-manifest.3985f0282363dee999087441606e595a.js
├── index.html
├── css
│ └── styles.css
└── service-worker.js
├── public
├── static
│ └── .gitkeep
└── index.template.html
├── src
├── view
│ └── home
│ │ ├── home.css
│ │ ├── home.html
│ │ └── home.js
├── assets
│ ├── main.scss
│ └── reset.scss
├── App.html
└── main.js
├── .babelrc
├── config
└── index.js
├── README.md
└── package.json
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
--------------------------------------------------------------------------------
/dist/static/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/public/static/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/view/home/home.css:
--------------------------------------------------------------------------------
1 | .home {
2 | color: #f00;
3 | }
--------------------------------------------------------------------------------
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["@babel/preset-env"]
3 | }
4 |
--------------------------------------------------------------------------------
/src/view/home/home.html:
--------------------------------------------------------------------------------
1 |
2 |
home page
3 |
4 |
--------------------------------------------------------------------------------
/src/view/home/home.js:
--------------------------------------------------------------------------------
1 | import Regular from 'regularjs';
2 | import tpl from './home.html'
3 | import './home.css'
4 | const Home = Regular.extend({
5 | template: tpl
6 | })
7 | export default Home
--------------------------------------------------------------------------------
/dist/precache-manifest.3985f0282363dee999087441606e595a.js:
--------------------------------------------------------------------------------
1 | self.__precacheManifest = [
2 | {
3 | "url": "/main.44b8066963e473df81af.js"
4 | },
5 | {
6 | "revision": "9141dd7d7c9d03b415390e5726b878c0",
7 | "url": "/index.html"
8 | },
9 | {
10 | "revision": "5884ded261bbe32e18fe",
11 | "url": "/css/styles.css"
12 | }
13 | ];
--------------------------------------------------------------------------------
/config/index.js:
--------------------------------------------------------------------------------
1 | // console.log(process.env.NODE_ENV)
2 | const config = {
3 | devServer: {
4 | host: 'localhost',
5 | port: 8080,
6 | proxy: {
7 | '/api': {
8 | target: 'http://localhost:3000',
9 | pathRewrite: {'^/api' : ''}
10 | }
11 | }
12 | }
13 | }
14 |
15 | module.exports = config
--------------------------------------------------------------------------------
/src/assets/main.scss:
--------------------------------------------------------------------------------
1 | .container {
2 | box-sizing: border-box;
3 | width: 100%;
4 | padding: 50px 0;
5 | text-align: center;
6 | font-size: 16px;
7 | font-weight: 100;
8 | .title {
9 | font-size: 32px;
10 | margin-bottom: 50px;
11 | }
12 | .info {
13 | line-height: 36px;
14 | font-size: 24px;
15 | a {
16 | text-decoration: none;
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/src/App.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/public/index.template.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | webpack-regular2.0
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/dist/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | webpack-regular2.0
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/dist/css/styles.css:
--------------------------------------------------------------------------------
1 | a,abbr,acronym,address,applet,article,aside,audio,b,big,blockquote,body,canvas,caption,center,cite,code,dd,del,details,dfn,div,dl,dt,em,embed,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,html,i,iframe,img,ins,kbd,label,legend,li,mark,menu,nav,object,ol,output,p,pre,q,ruby,s,samp,section,small,span,strike,strong,sub,summary,sup,table,tbody,td,tfoot,th,thead,time,tr,tt,u,ul,var,video{margin:0;padding:0;border:0;font:inherit;vertical-align:baseline}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}li,ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:after,blockquote:before,q:after,q:before{content:"";content:none}table{border-collapse:collapse;border-spacing:0}.container{box-sizing:border-box;width:100%;padding:50px 0;text-align:center;font-size:16px;font-weight:100}.container .title{font-size:32px;margin-bottom:50px}.container .info{line-height:36px;font-size:24px}.container .info a{text-decoration:none}.home{color:red}
--------------------------------------------------------------------------------
/src/main.js:
--------------------------------------------------------------------------------
1 | import Regular from 'regularjs';
2 | // regular 路由
3 | import restate from 'regular-state';
4 | // 兼容ie浏览器,如果不需要请勿引入,会导致包过大
5 | // import "babel-polyfill";
6 | import './assets/reset.scss';
7 | import './assets/main.scss';
8 | import AppTpl from './App.html';
9 | import Home from './view/home/home';
10 |
11 | const App = Regular.extend({
12 | template: AppTpl
13 | })
14 |
15 | const routes = {
16 | '/': {
17 | view: App
18 | },
19 | '/home': {
20 | view: Home
21 | }
22 | }
23 |
24 | const manager = restate().state(routes)
25 | manager.start({
26 | view: document.getElementById('app') //顶层容器节点
27 | })
28 |
29 | if ('serviceWorker' in navigator) {
30 | window.addEventListener('load', () => {
31 | navigator.serviceWorker.register('/service-worker.js').then(registration => {
32 | console.log('SW registered: ', registration);
33 | }).catch(registrationError => {
34 | console.log('SW registration failed: ', registrationError);
35 | });
36 | });
37 | }
38 |
--------------------------------------------------------------------------------
/dist/service-worker.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Welcome to your Workbox-powered service worker!
3 | *
4 | * You'll need to register this file in your web app and you should
5 | * disable HTTP caching for this file too.
6 | * See https://goo.gl/nhQhGp
7 | *
8 | * The rest of the code is auto-generated. Please don't update this file
9 | * directly; instead, make changes to your Workbox build configuration
10 | * and re-run your build process.
11 | * See https://goo.gl/2aRDsh
12 | */
13 |
14 | importScripts("https://storage.googleapis.com/workbox-cdn/releases/3.6.3/workbox-sw.js");
15 |
16 | importScripts(
17 | "/precache-manifest.3985f0282363dee999087441606e595a.js"
18 | );
19 |
20 | workbox.skipWaiting();
21 | workbox.clientsClaim();
22 |
23 | /**
24 | * The workboxSW.precacheAndRoute() method efficiently caches and responds to
25 | * requests for URLs in the manifest.
26 | * See https://goo.gl/S9QRab
27 | */
28 | self.__precacheManifest = [].concat(self.__precacheManifest || []);
29 | workbox.precaching.suppressWarnings();
30 | workbox.precaching.precacheAndRoute(self.__precacheManifest, {});
31 |
--------------------------------------------------------------------------------
/src/assets/reset.scss:
--------------------------------------------------------------------------------
1 | /* creat by 2018-11-26
2 | */
3 | // reset 模块
4 | html, body, div, span, applet, object, iframe,
5 | h1, h2, h3, h4, h5, h6, p, blockquote, pre,
6 | a, abbr, acronym, address, big, cite, code,
7 | del, dfn, em, img, ins, kbd, q, s, samp,
8 | small, strike, strong, sub, sup, tt, var,
9 | b, u, i, center,
10 | dl, dt, dd, ol, ul, li,
11 | fieldset, form, label, legend,
12 | table, caption, tbody, tfoot, thead, tr, th, td,
13 | article, aside, canvas, details, embed,
14 | figure, figcaption, footer, header, hgroup,
15 | menu, nav, output, ruby, section, summary,
16 | time, mark, audio, video {
17 | margin: 0;
18 | padding: 0;
19 | border: 0;
20 | font: inherit;
21 | vertical-align: baseline;
22 | }
23 | /* HTML5 display-role reset for older browsers */
24 | article, aside, details, figcaption, figure,
25 | footer, header, hgroup, menu, nav, section {
26 | display: block;
27 | }
28 | body {
29 | line-height: 1;
30 | }
31 | ol, ul, li {
32 | list-style: none;
33 | }
34 | blockquote, q {
35 | quotes: none;
36 | }
37 | blockquote:before, blockquote:after,
38 | q:before, q:after {
39 | content: '';
40 | content: none;
41 | }
42 | table {
43 | border-collapse: collapse;
44 | border-spacing: 0;
45 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## 基于webpack的regularjs应用模板
2 |
3 | ### 使用
4 | #### 1. 使用 regular-cli 初始化项目
5 | - 全局安装
6 | ```bash
7 | npm install -g regular-cli
8 | ```
9 | - 初始化项目
10 | ```bash
11 | regular init
12 | ```
13 | - 示例
14 | ```bash
15 | regular init test-project
16 | cd test-project
17 | # 安装依赖
18 | npm install
19 | # 开发环境
20 | npm run dev
21 | # 生产环境
22 | npm run build
23 | ```
24 |
25 | #### 2. github下载
26 | [https://github.com/fisher-zh/webpack-regular](https://github.com/fisher-zh/webpack-regular)
27 |
28 | ### 简介
29 | 该模板基于 webpack4.x regular regular-state 构建,目前已提供基础的开发功能,可以基于该模板进行单页面、多页面系统的开发。
30 | 当然,如果你不喜欢内置的 regular regular-state ,你完全可以通过修改入口文件(main.js),增加其他框架支持的 loader 来进行开发。
31 |
32 | 在构建该模板的过程中,并没有使用类似 vue 模板的方法对一些 webpack 的方法和插件进行封装,
33 | 一方面由于时间和技术内管理有限,不能进行完备的测试,如果开发人员在使用过程中出现问题将难以定位和解决;
34 | 另一方面,直接暴露出原有的文件给开发者可以提供更大的自由度。
35 |
36 | ### 目录
37 | ```
38 | |-- build webpack配置和打包脚本
39 | |-- config 部分webpack配置
40 | |-- dist 编译后文件目录
41 | |-- node_modules
42 | |-- public 静态资源和模板文件
43 | |-- src 项目文件夹
44 | |-- assets 资源
45 | |-- components 组件
46 | |-- view 页面级组件
47 | |-- main.js 项目入口
48 | |-- package.json
49 | |-- README.md
50 | ```
51 |
52 |
53 | ### 参考文档
54 | [regularjs](http://regularjs.github.io/guide/)
55 | [regular-state](https://regularjs.github.io/regular-state/)
56 |
57 | ### 最后
58 | 欢迎各位使用者star和issue,作者将会尽快回复您的问题,商业联系邮箱:fisher_zh@163.com
59 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "webpack-regular2.0",
3 | "version": "2.0.0",
4 | "description": "a regularjs project base on webpack",
5 | "main": "index.js",
6 | "scripts": {
7 | "dev": "webpack-dev-server --config build/webpack.dev.config.js",
8 | "build": "node build/build.js"
9 | },
10 | "repository": {
11 | "type": "git",
12 | "url": "git+https://github.com/fisher-zh/webpack-regular.git"
13 | },
14 | "keywords": [
15 | "regular",
16 | "webpack"
17 | ],
18 | "author": "fisher-zh",
19 | "license": "MIT",
20 | "bugs": {
21 | "url": "https://github.com/fisher-zh/webpack-regular/issues"
22 | },
23 | "homepage": "https://github.com/fisher-zh/webpack-regular#readme",
24 | "devDependencies": {
25 | "@babel/plugin-transform-runtime": "^7.1.0",
26 | "@babel/preset-env": "^7.2.0",
27 | "babel-plugin-transform-runtime": "^6.23.0",
28 | "copy-webpack-plugin": "^4.6.0",
29 | "css-loader": "^1.0.1",
30 | "html-webpack-plugin": "^3.2.0",
31 | "less": "^3.9.0",
32 | "less-loader": "^4.1.0",
33 | "style-loader": "^0.23.1",
34 | "webpack": "^4.26.1",
35 | "webpack-cli": "^3.1.2",
36 | "webpack-dev-server": "^3.1.10",
37 | "workbox-webpack-plugin": "^3.6.3"
38 | },
39 | "dependencies": {
40 | "@babel/core": "^7.1.6",
41 | "@babel/runtime": "^7.1.5",
42 | "babel-loader": "^8.0.0-beta.0",
43 | "babel-polyfill": "^6.26.0",
44 | "babel-runtime": "^6.26.0",
45 | "chalk": "^2.4.1",
46 | "mini-css-extract-plugin": "^0.4.5",
47 | "node-sass": "^4.10.0",
48 | "optimize-css-assets-webpack-plugin": "^5.0.1",
49 | "ora": "^3.0.0",
50 | "raw-loader": "^0.5.1",
51 | "regular-state": "^0.6.0-beta.9",
52 | "regularjs": "^0.6.0",
53 | "rimraf": "^2.6.2",
54 | "sass-loader": "^7.1.0",
55 | "spinner": "^0.3.4",
56 | "webpack-merge": "^4.1.4"
57 | }
58 | }
59 |
--------------------------------------------------------------------------------