Webpack和svgstore,如何?
我正在尝试配置Webpack以使用 然而,我有点卡住了,不能让它工作。。。 我的webpack配置基于vue cli中的webpack simple 我的所有svg文件都存储在Webpack和svgstore,如何?,webpack,vue.js,Webpack,Vue.js,我正在尝试配置Webpack以使用 然而,我有点卡住了,不能让它工作。。。 我的webpack配置基于vue cli中的webpack simple 我的所有svg文件都存储在“src/assets/svg/”——我希望它将svg精灵输出到/dist/文件夹中 目前,在运行npm run build 我的网页包文件看起来像: var path = require('path'); var webpack = require('webpack'); var SvgStore = require('
“src/assets/svg/”
——我希望它将svg精灵输出到/dist/
文件夹中
目前,在运行npm run build
我的网页包文件看起来像:
var path = require('path');
var webpack = require('webpack');
var SvgStore = require('webpack-svgstore-plugin');
var sourcePath = path.join('src');
module.exports = {
entry: './src/main.js',
output: {
path: path.resolve(__dirname, './dist/'),
publicPath: '/dist/',
filename: 'build.js'
},
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: {
// Since sass-loader (weirdly) has SCSS as its default parse mode, we map
// the "scss" and "sass" values for the lang attribute to the right configs here.
// other preprocessors should work out of the box, no loader config like this necessary.
'scss': 'vue-style-loader!css-loader!sass-loader',
'sass': 'vue-style-loader!css-loader!sass-loader?indentedSyntax'
}
// other vue-loader options go here
}
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader',
options: {
name: '/img/[name].[ext]?[hash]'
}
}
]
},
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js'
}
},
devServer: {
historyApiFallback: true,
noInfo: true
},
performance: {
hints: false
},
devtool: '#eval-source-map',
plugins: [
new SvgStore(
path.join(sourcePath, 'assets', 'svg', '*.svg'),
'dist',
{
name: 'sprite.[hash].svg',
chunk: 'src',
svgoOptions: {
}
})
]
}
这方面有进展吗?我正在寻找相同的;)您可以检查我使用的易集成和易使用的VueJS
if (process.env.NODE_ENV === 'production') {
module.exports.devtool = '#source-map'
// http://vue-loader.vuejs.org/en/workflow/production.html
module.exports.plugins = (module.exports.plugins || []).concat([
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compress: {
warnings: false
}
}),
new webpack.LoaderOptionsPlugin({
minimize: true
})
])
}