码迷,mamicode.com
首页 > Web开发 > 详细

webpack

时间:2018-09-02 20:56:20      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:webp   hub   tag   ESS   erro   tput   template   depend   eset   

json文件

{
  "name": "webpack-study",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "dev": "webpack-dev-server --open --port 8080 --hot"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "babel-core": "^6.26.0",
    "babel-loader": "^7.1.2",
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-preset-env": "^1.6.1",
    "babel-preset-stage-0": "^6.24.1",
    "css-loader": "^0.28.7",
    "file-loader": "^1.1.5",
    "html-webpack-plugin": "^2.30.1",
    "less": "^2.7.3",
    "less-loader": "^4.0.5",
    "node-sass": "^4.5.3",
    "sass-loader": "^6.0.6",
    "style-loader": "^0.19.0",
    "url-loader": "^0.6.2",
    "webpack": "^3.8.1",
    "webpack-dev-server": "^2.9.3"
  },
  "dependencies": {
    "bootstrap": "^3.3.7"
  }
}

配置文件


var path = require(‘path‘);
var htmlWebpackPlugin = require(‘html-webpack-plugin‘);

module.exports = {
  entry: path.join(__dirname, ‘./src/main.js‘),
  output: {
    path: path.join(__dirname, ‘./dist‘),
    filename: ‘bundle.js‘
  },
  plugins: [
    new htmlWebpackPlugin({
      template: path.join(__dirname, ‘./src/index.html‘),
      filename: ‘index.html‘
    })
  ],
  module: {
    rules: [
      { test: /\.css$/, use: [‘style-loader‘, ‘css-loader‘] },
      { test: /\.less$/, use: [‘style-loader‘, ‘css-loader‘, ‘less-loader‘] },
      { test: /\.scss$/, use: [‘style-loader‘, ‘css-loader‘, ‘sass-loader‘] },
      { test: /\.(jpg|png|gif|bmp|jpeg)$/, use: ‘url-loader?limit=10394 ‘ },
      { test: /\.(ttf|eot|svg|woff|woff2)$/, use: ‘url-loader‘ },
      { test: /\.js$/, use: ‘babel-loader‘, exclude: /node_modules/ },
    ]
  }
}

完整demo

https://github.com/Jasonlincoln/webStudy

webpack

标签:webp   hub   tag   ESS   erro   tput   template   depend   eset   

原文地址:https://www.cnblogs.com/Jason-lin/p/9575193.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!