-
-
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
How to output all the assets to a specific directory like static
?
#1027
Comments
I use this module.exports = {
chainWebpack: config => {
config.output
.filename('static/js/[name].[chunkhash:8].js')
}
}; |
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
/*
vue inspect --mode production > output.js
[read some source code](https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-service/lib/config)
*/
module.exports = {
compiler: true,
devServer: {
proxy: {
'/php/': {
target: process.env.SERVICE_URL,
changeOrigin: true,
pathRewrite: {
'^/php/': '/'
}
}
}
},
chainWebpack: webpackConfig => {
if (process.env.NODE_ENV === 'production') {
const inlineLimit = 10000;
const assetsPath = 'static/assets';
webpackConfig
.output
.filename(path.join(assetsPath, 'js/[name].[chunkhash:8].js'))
.chunkFilename(path.join(assetsPath, '/js/chunk[id].[chunkhash:8].js'))
webpackConfig.plugin('extract-css')
.use(ExtractTextPlugin, [{
filename: path.join(assetsPath, 'css/[name].[contenthash:8].css'),
allChunks: true
}])
webpackConfig.module
.rule('images')
.test(/\.(png|jpe?g|gif)(\?.*)?$/)
.use('url-loader')
.loader('url-loader')
.options({
limit: inlineLimit,
name: path.join(assetsPath, 'img/[name].[hash:8].[ext]')
})
webpackConfig.module
.rule('fonts')
.test(/\.(woff2?|eot|ttf|otf)(\?.*)?$/i)
.use('url-loader')
.loader('url-loader')
.options({
limit: inlineLimit,
name: path.join(assetsPath, 'fonts/[name].[hash:8].[ext]')
})
}
}
}; |
@korewayume this does not work with new the vue cli with webpack 4 |
|
@korewayume thanks!!! |
note i have used this
|
As @rhymes said it has been fixed in Vue CLI 3. You will need to insert
In your configuration to compile assets to the static/ folder. |
@korewayume how can i use this to the package css(js) has hash bug pictures not |
What problem does this feature solve?
how to change the output assets path?
I mean move dist/js to dist/static/js and dist/css to dist/static/css.
I tried use baseUrl or publicPath option in vue.config.js, but it doesn't work.
What does the proposed API look like?
provide an option to configure the
assetsSubDirectory
The text was updated successfully, but these errors were encountered: