modules和webpack.config.js初建

1.npm init 初始化项目,创建了package.json文件

2.npm install webpack-cli --save-dev 安装webpack-cli,不建议全局安装,这样可以在多个项目中使用不同项目的webpack版本(文件夹多出来node_modules)

3.npm install webpack --save 安装webpack

4.npx webpack index.js   项目运行出现(dist文件夹)

目录结构


4180367-2231b99ef0059a11.png
目录结构

使用知识点

1.Common.js  

    require  引入文件

    moule.exports = a  抛出方法

2.ES2015(es6)

    import 引入文件

    export defalut 方法名   抛出方法名

3.css/sass/less

@import 文件名

4.创建webpack.config.js   模块打包配置文件


4180367-5e03dce8952be6ab.png
webpack.config.js

5.更改webpack.config.js的名字     webpack --config 名字

转载于:https://www.jianshu.com/p/66456dabfdd7

猜你喜欢

转载自blog.csdn.net/weixin_34161083/article/details/91294708