Code Monkey home page Code Monkey logo

webpack-seed's Introduction

Webpack

Webpack babel License

前言

开箱即用的多页面模板, 基于 webpack4 babel7 开发可复用的现代化网站, 解决非 SPA 应用, html 复用, 模块化开发编译等问题.

如果感兴趣该项目, 请点个 star

及时关注项目更新, 请点个 watch

项目 bug, 请提 issue

新版本 2.x

  • 使用webpack-chain进行构建程序
  • 重构整体页面配置, 包括模板的创建, 静态第三方资源的引入方式
  • 全新的变量管理方式, 类 vue-cli 脚手架的配置, 自动读取根目录的环境变量文件.env[mode]
  • 支持在ws.config.js进行全局的配置打包等配置, 具体可参考 vue.config.js 配置方式

特性

  • 支持前后端分离开发
  • 配置完整的打包方案
  • 支持本地开发热更新
  • EJS 模板编译
  • 图片处理压缩
  • 内置 Sass 开发环境
  • 集成代码风格校验 Eslint
  • 内置字体图标库 500+, 开箱即用
  • 支持 ES6 语法,编译生成生产代码
  • 支持开发(生产)环境变量注入(基于.env.[mode]文件,类似于 Vue-CLI 脚手架提供的方案)
  • 通用的构建方式, 基本是开箱即用. 同时支持通过ws.config.js进行灵活的构建配置
  • ...

注:本项目引入了 jquery, bootstrap,该文件配置可自动加载第三方脚本作为链接使用(script 标签的形式引入), 如果需要,在 src/common/lib/index.js 配置即可

项目结构

webpack-seed
├── dist # 输出目录
├── bin # 创建页面命令
├── build # webpack构建目录
├── src # 项目主目录
├── .editorconfig
├── .env.github # 环境变量配置
├── .env.prod # 环境变量配置
├── .env.staging # 环境变量配置
├── .eslintignore
├── .eslintrc.js
├── .gitignore
├── .npmrc # npm源
├── .postcssrc.js
├── .prettierignore
├── .prettierrc.js
├── .travis.yml # CI当前项目demo部署
├── favicon.ico
├── LICENSE
├── README.md
├── babel.config.js # babel配置
├── package.json
├── ws.config.js # 可通过该配置改webpack等配置
└── yarn.lock

输出

dist
├── css
├── favicon.ico
├── fonts
├── html
├── image
├── index.html
├── js
└── libs

使用

下载使用

git clone https://github.com/BiYuqi/webpack-seed.git

cd webpack-seed

yarn install

本地开发(dev)

yarn run serve

打包(build)

yarn run build

配置文件

# 具体配置和vue.config.js一致
ws.config.js

环境变量

# 具体配置和vue-cli配置方式一致
.env[mode]

TODO

  • 测试框架默认 Jest
  • 编写创建项目的脚手架, eslint, jest, 等配置可选
  • 优化 webpack 配置流程, 尽量黑盒化, 约定大于配置
  • 文档补充

webpack-seed's People

Contributors

biyuqi avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

webpack-seed's Issues

关于 windows平台下 warning Delete `␍` prettier/prettier(eslint配置的一些问题)

报错截图

image

解决办法

使用git执行以下命令关掉自动转化(git默认是打开的)
1、git config --global core.autocrlf false
2、删除代码重新git clone https://github.com/BiYuqi/webpack-seed

原因

在window系统中,clone代码下来,会自动把换行符LF(linefeed character) 转换成回车符CRLF(carriage-return character)。这时候我们本地的代码都是回车符。

参考网址:https://blog.csdn.net/LPLIFE/article/details/105655178

需求收集

如果你对项目有更好的建议请在此处提出.

yarn run serve 又出现了 新的报错

ERROR in Entry module not found: Error: Can't resolve './src' in 'D:[Code_Dev]\webpack-seed-1'

ERROR in multi (webpack)-dev-server/client?http://localhost:8080 (webpack)/hot/dev-server.js ./src
Module not found: Error: Can't resolve './src' in 'D:[Code_Dev]\webpack-seed-1'
@ multi (webpack)-dev-server/client?http://localhost:8080 (webpack)/hot/dev-server.js ./src main[2]
image

运行报错

Uncaught Error: Module build failed (from ./node_modules/sass-loader/lib/loader.js):
Error: ENOENT: no such file or directory, scandir 'd:\Jerry2016\work\XXX\webpack-seed\node_modules\node-sass\vendor'
at Object.fs.readdirSync (fs.js:904:18)

打包之后的问题

打包之后打开index.html 。控制台会报错 Uncaught SyntaxError: Unexpected token <

npm dev 报错

Project is Running at 8080
× 「wds」: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.

  • configuration.entry should be an non-empty object.
    -> Multiple entry bundles are created. The key is the chunk name. The value can be a string or an array.
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! [email protected] dev: webpack-dev-server --open --inline --mode development --config build/webpack.dev.config
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the [email protected] dev script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.