티스토리 뷰
index.js
import _ from "lodash";
import "./style.css";
import Vue from 'vue';
var app = new Vue({
el: '#app',
data: {
message: '안녕하세요 Vue!'
}
})
webpack.config.js
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
module.exports = {
mode: "development",
entry: "./src/index.js",
devtool: "inline-source-map",
plugins: [
new HtmlWebpackPlugin({
title: "Output Management",
template: "index.html"
}),
new CleanWebpackPlugin(),
],
devServer: {
contentBase: "./dist",
hot: true,
},
output: {
filename: "bundle.js",
path: path.resolve(__dirname, "dist")
},
module: {
rules: [
{
test: /\.css$/,
use: ["style-loader", "css-loader"]
},
{
test: /\.(png|svg|jpg|gif)$/,
use: ["file-loader"]
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/,
use: ["file-loader"]
},
{
test: /\.(csv|tsv)$/,
use: ["csv-loader"]
},
{
test: /\.xml$/,
use: ["xml-loader"]
}
]
},
resolve: {
alias: {
vue: 'vue/dist/vue.esm.js'
}
}
};
더보기
하단에 위치한 resolve > alias > vue를 추가해주고 경로를 입력해주면
index.js에서 import Vue from 'vue' 라고 간단하게 정의해줄 수 있습니다.
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div id="app">
{{ message }}
</div>
</body>
</html>
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크