Git Product home page Git Product logo

webpack-multiple-page's Introduction

clarence webpack demo

安装环境

#npm 更换淘宝源
npm config set registry https://registry.npm.taobao.org
# 安装yarn
npm install yarn -g

#yarn 更换淘宝源
yarn config set registry https://registry.npm.taobao.org -g

#yarn 设置 node-sass 参数
npm config set sass_binary_site=s://npm.taobao.org/mirrors/node-sass/ -g
yarn config set sass_binary_site https://npm.taobao.org/mirrors/node-sass/ -g

安装依赖

yarn
## or
npm i

最后 打包

npm run build
## or
yarn build

文件目录

html 文件写在src/html目录下,页面js请写在src/js对应目录中。

html 使用 ejs模板,如果有页面参数数据,请写在对应的src/data目录下

ejs文件中 使用 <div><%= htmlWebpackPlugin.options.data %></div>来使用数据

例:

src/data/index.json中定义数据

{
    "testData": "test"
}

src/html/index.ejs使用数据

<div><%= htmlWebpackPlugin.options.data.testData %></div>
<!-- 会被编译成<div>test</div> -->

修改完后最好重启一下用以编译模板

static 会整体copy到dist目录下

src/common文件夹放公共js文件

src/style/scss中 有公共样式,页面样式请在页面js文件中单独importscss文件进来。

webpack-multiple-page's People

Contributors

s749312025 avatar

Watchers

 avatar

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.