-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a build --watch flag that writes to the disk in development #1120
Comments
A quick workaround, until this feature is possibly added could be to add the following entry to the |
Awesome! That seems to work nicely. |
You should also be able to have the dev-server write its files to the disk like this: // vue.config.js
module.exports = {
devServer: {
inline: false // https://webpack.js.org/configuration/dev-server/#devserver-inline
}
} or maybe you need this: https://github.com/gajus/write-file-webpack-plugin // vue.config.js
const WritePlugin = require('write-file-webpack-plugin')
module.exports = {
configureWebpack: {
plugins: [
new WritePlugin()
]
}
} |
@LinusBorg The first option didn't seem to do the trick a quick test (not seeing a dist folder be created when I run |
I started to build a own cli-plugin for exactly this, because our applications are integrated into thymeleaf. My main problem is that I want to edit the webpack config and then execute the The code looks somehow like this currently:
Or do I miss something which would make it much easier to achieve this goal? |
Give this a try: module.exports = (api) => {
api.registerCommand('build-watch', (...args) => {
api.configureWebpack(webpackConfig => {
webpackConfig.watch = true
});
api.service.run('build', ...args)
});
}; |
@LinusBorg works like a charm 😃 thanks! Will post the plugin here once I published it |
This comment has been minimized.
This comment has been minimized.
It should be noted that @zwenza's plugin outputs a flattened directory structure than when you run the |
True. I tested @zwenza 's code and it flattens the js directory. I am developing a chrome extension and so the |
Okay. So after a little bit of fiddling, you can prevent the flattening of the js directory by specifying the output file name in the module.exports = {
chainWebpack(config) {
config.output.filename("js/[name].js");
}
} And you don't need to install additional plug-ins, you can just run:
or add it into your "scripts": { |
I came here through a duckduckgo search and the answer is almost here. // vue.config.js
module.exports = {
devServer: {
writeToDisk: true // https://webpack.js.org/configuration/dev-server/#devserverwritetodisk-
}
} |
But after adding
Images and other types of assets omitted. And no CSS file is being created!? |
None of the solutions given above seems to compile CSS files on development. Any workaround for this ? |
@ijunaid8989 try add "scripts": {
"serve": "vue-cli-service serve",
"watch": "NODE_ENV=production vue-cli-service build --watch --mode development",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
}, you can read more here https://cli.vuejs.org/guide/mode-and-env.html#modes |
actually you can just add css: {
extract: true
} into your |
@axe-me |
What problem does this feature solve?
I would like to serve the Vue as a SPA app inside of the ASP.NET application. With the existing
serve
command, I do not have access to the files on the disk, so I cannot accomplish that. With a build --watch flag, it would run the webpack build, watch for file changes, and run the build on file changes.Ionic supports this (ionic-app-scripts watch), Angular CLI supports this (ng build --watch), and these allow me to write Angular/Ionic apps and use them as part as my web application.
What does the proposed API look like?
vue-cli-service build --watch
orvue-cli-service watch
.The text was updated successfully, but these errors were encountered: