Webpack

  • 安装
install i webpack -g#全局安装
install i webpack -D#局部安装
  • 创建webpack.config.js
module.exports = {
  entry: './main.js',
  output: {
    filename: 'bundle.js'
  }
};

#main.js
require('./hello.js');
console.log('I am is main.js');

#hello.js
console.log('I am is hello.js');

#控制台
webpack
node bundle.js
Paste_Image.png
  • loaders
#webpack.config.js
npm i style-loader css-loader sass-loader autoprefixer-loader  babel-loader -D

module.exports = {
  entry: './main.js',
  output: {
    filename: 'bundle.js'
  },
  module: {
    loaders: [
      { test: /\.js$/,   loader: "babel" },
      { test: /\.scss$/, loader: "style!sass!autoprefixer!css"}
    ]
  }
};

你可能感兴趣的:(Webpack)