> For the complete documentation index, see [llms.txt](https://azr.gitbook.io/webpack/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://azr.gitbook.io/webpack/webpack+vue/ji-ben-pei-zhi.md).

# 基本配置

### 安装依赖

```
$ npm i style-loader css-loader -D
$ npm i vue vue-loader vue-template-compiler -D
```

### vue-loader

由于`vue-loader`的版本是`^15.4.2` 需要再次进行配置

```
const VueLoaderPlugin = require('vue-loader/lib/plugin')
module.exports = {
    // .... 
    plugins: [
    new VueLoaderPlugin(),
  ]
}
```

### html-webpack-plugin

配置插件 `html-webpack-plugin`

```
$ npm i webpack webpack-cli webpack-dev-server  html-webpack-plugin -D
```

```
var HtmlWebpackPlugin = require('html-webpack-plugin');
var path = require('path');

module.exports = {
    entry: 'index.js',
    output: {
      path: path.resolve(__dirname, './dist'),
      filename: 'bundle.js'
    },
    plugins: [
    new HtmlWebpackPlugin(),
  ]
}
```

### 最终代码

```
const path = require("path");
const VueLoaderPlugin = require('vue-loader/lib/plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')

module.exports = {
  mode: "development",
  entry: "./src/main.js",
  output: {
    path: path.join(__dirname, "dist"),
    filename:'bundle.js'
  },
  module: {
    rules: [
      {
        test: /\.css$/,
        use: ["style-loader", "css-loader"]
      },
      {
        test: /\.vue$/,
        use: ["vue-loader"]
      }
    ]
  },
  plugins: [
    new VueLoaderPlugin(),
    new HtmlWebpackPlugin({
      template:'./template.html'
    })
  ]
};

```
