webpack打包layui实现步骤


当前第2页 返回上一页

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

const webpack = require('webpack')

 

module.exports = {

  entry: {

    home: './static/js/home.js',

    download: './static/js/download.js',

  },

  output: {

    path: __dirname + '/dist',

    filename: '[name].bundle.js',

  },

  module: {

    rules: [

      {

        test: /\.(otf|eot|svg|ttf|woff|woff2)$/,

        use: [

          {

            loader: 'url-loader',

            options: {

              name: '[name].[ext]',// 打包后的文件名称

              outputPath: '', // 默认是dist目录

              publicPath: '../font/', // 图片的url前面追加'../font'

              useRelativePath: true, // 使用相对路径

              limit: 50000 // 表示小于1K的图片会被转化成base64格式

            }

          }

        ]

      },

      {

        test: /\.(jpe?g|png|gif|svg)$/i,

        use: [

          {

            loader: 'file-loader',

            options: {

              name: '[hash:3]_[name].[ext]',// 打包后的文件名称

              outputPath: '',

              publicPath: '../img/',

              useRelativePath: true

            }

          }

        ]

      },

      {

        test: /\.css$/,

        use: [

          { loader: 'style-loader' },

          {

            loader: 'css-loader',

            options: {

              modules: true,

              getLocalIdent: (context, localIdentName, localName, options) => {

                return localName

              }

            }

          },

        ]

      },

      { test: /\.js$/, exclude: /node_modules/, use: 'babel-loader' },

    ]

  },

  plugins: [

    new webpack.ProvidePlugin({

      $: 'jquery',

      jQuery: 'jquery',

      "window.jQuery": "jquery"

    })

  ],

  mode: 'development'

}

以上就是webpack打包layui实现步骤的详细内容,更多文章请关注木庄网络博客

返回前面的内容

相关阅读 >>

layui框架的flow组件常见用法总结

layui怎么使用jquery

layui时间控件选择时间

怎么使用vue-cli来搭建vue项目和webpack

layui怎么绑定普通事件监听

layui项目中使用函数layui.define的方法介绍

layui怎么引用

让layui支持es5写法的方法介绍

webpack打包layui实现步骤

layui数据表格url是什么

更多相关阅读请进入《webpack》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...