반응형
webpack,vue.dll,vue 파일을 컴파일할 수 없습니다.
vue.js와 webpack은 처음이라 vue 파일을 컴파일하는 데 문제가 있습니다.
템플릿 테크놀로지로 Spring boot과 pebble을 사용하고 있습니다.단일 .js 파일을 생성하여 인덱스에 포함시키고 싶습니다.
여기 webpack.config.js가 있습니다.
module.exports = {
// This is the "main" file which should include all other modules
entry: './src/main/resources/static/app/main.js',
// Where should the compiled file go?
output: {
// To the `dist` folder
path: './src/main/resources/static/lib',
// With the filename `build.js` so it's dist/build.js
filename: 'build.js'
},
module: {
// Special compilation rules
loaders: [
{
// Ask webpack to check: If this file ends with .js, then apply some transforms
test: /\.js$/,
// Transform it with babel
loader: 'babel',
// don't transform node_modules folder (which don't need to be compiled)
exclude: /node_modules/
},
{
test: /\.vue$/,
loader: 'vue'
}
]
},
vue: {
loaders: {
js: "babel-loader?presets[]=es2015,presets[]=stage-2"
}
},
}
my file babelrc :
{
"presets": ["es2015", "stage-0"],
"plugins": ["transform-runtime"]
}
파일 패키지json
{
"name": "xxxx",
"version": "1.0.0",
"description": "TODO",
"scripts": {
"watch-build": "echo \"not available\" && exit 1",
"build": "npm install",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "LMFR",
"readmeFilename": "README.md",
"devDependencies": {
"babel-core": "^6.1.2",
"babel-loader": "^6.1.0",
"babel-preset-latest": "^6.16.0",
"babel-preset-stage-2": "^6.18.0",
"babel-runtime": "^5.8.0",
"webpack": "^1.12.2",
"css-loader": "^0.23.0",
"style-loader": "^0.13.0",
"vue-loader": "^7.3.0",
"vue-html-loader": "^1.0.0"
},
"dependencies": {
"vue": "^2.3.2"
}
}
여기 제 메인입니다.js
'vue'에서 Vue 가져오기 // '.app.vue'에서 앱 가져오기
new Vue({
el: '#app',
template: '<p>haaaa</p>'
})
그리고 내가 직면한 오류:
build.js:494 [Vue warn]: You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build.
가이드로서 webpack-simple vue-cli 템플릿을 참조해 주세요.의존관계가 없는 것 같습니다.
https://github.com/vuejs-templates/webpack-simple/blob/master/template/package.json#L26
"vue-template-compiler": "^2.2.1",
런타임 빌드만 있는 경우 템플릿 속성을 사용할 수 없으며 대신 렌더 함수를 사용하거나 템플릿 컴파일러를 포함해야 합니다.
main.main을 로 변경해 보겠습니다.
import Vue from 'vue' //import App from './app.vue'
new Vue({
el: '#app',
render: function(createElement) {
return createElement(
'p',
'haaaa'
)
}
})
JsFiddle 워킹 바이올린
웹 팩 사용 시.vue
파일을 컴파일할 수 있습니다.<template></template>
태그 단, 메인 Vue 루트는 일반적으로 다음과 같이 보이는 렌더 함수를 사용해야 합니다.
import Vue from 'vue'
import App from './app.vue'
new Vue({
el: '#app',
render: function(createElement) {
return createElement(
App
)
}
})
언급URL : https://stackoverflow.com/questions/43855862/webpack-vue-js-cant-compile-vue-file
반응형
'sourcecode' 카테고리의 다른 글
LD_PRELOAD 메커니즘을 사용한 'malloc' 재정의 (0) | 2022.08.07 |
---|---|
VueJs 및 Larabel을 사용하여 여러 파일 업로드 (0) | 2022.08.07 |
변환에서 푸시할 때 Vuex 저장소에서 구성 요소 컬렉션을 업데이트하지 않음 (0) | 2022.08.07 |
타입 번호의 입력에 대해서, 증감 처리를 덮어쓰는 방법이 있습니까? (0) | 2022.08.03 |
여러 스레드에서 stdlib의 rand() 사용 (0) | 2022.08.03 |