Javascript rollup.js_Bundle自动更新
我正在尝试通过VSCode中的rollup.js绑定Javascript rollup.js_Bundle自动更新,javascript,html,bundle,vscode-settings,rollupjs,Javascript,Html,Bundle,Vscode Settings,Rollupjs,我正在尝试通过VSCode中的rollup.js绑定 My directory: ----MyProject --------\node_modules -----------\.bin -----------\rollup --------index.js --------index.html --------bundle.js --------package-lock.json --------package.json 在我的.html文件中,我与bundle.js有连接,我在index
My directory:
----MyProject
--------\node_modules
-----------\.bin
-----------\rollup
--------index.js
--------index.html
--------bundle.js
--------package-lock.json
--------package.json
在我的.html
文件中,我与bundle.js
有连接,我在index.js
中所做的所有更改都必须在bundle.js中自动更新。但它只有在终端中运行以下命令时才起作用:rollup index.js--file bundle.js
Mypackage.json
:
{
"name": "npm",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"rollup": "^2.34.2"
}
}
"build": "rollup -c",
"dev": "rollup -c -w"
我需要做什么才能使这个系统自动工作?首先,我没有配置文件,所以我创建了
rollup.config.js
:
import serve from 'rollup-plugin-serve'
import livereload from 'rollup-plugin-livereload'
const watch = process.env.ROLLUP_WATCH
export default {
input: 'src/index.js',
output: {
file: 'dist/bundle.js',
format: 'iife'
},
plugins: [
watch && serve('dist'),
watch && livereload()
]
}
然后我将这两个脚本添加到package.json
:
{
"name": "npm",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"rollup": "^2.34.2"
}
}
"build": "rollup -c",
"dev": "rollup -c -w"
并在终端中运行:npm-run-dev
我的信用卡需要帮助