Merge branch 'mg-update-icons-svg-import' into 'master'

Use file-loader for sprite icons within icon.vue

See merge request gitlab-org/gitlab-ce!31257
This commit is contained in:
Kushal Pandya 2019-07-31 09:02:48 +00:00
commit 4b2ea22caf
3 changed files with 20 additions and 1 deletions

View File

@ -0,0 +1,3 @@
// any import of '@gitlab/svgs/dist/icons.svg' will be overridden with this
// to avoid asset duplication between sprockets and webpack
export default gon && gon.sprite_icons;

View File

@ -1,4 +1,6 @@
<script>
import iconsPath from '@gitlab/svgs/dist/icons.svg';
// only allow classes in images.scss e.g. s12
const validSizes = [8, 10, 12, 14, 16, 18, 24, 32, 48, 72];
let iconValidator = () => true;
@ -84,7 +86,7 @@ export default {
computed: {
spriteHref() {
return `${gon.sprite_icons}#${this.name}`;
return `${iconsPath}#${this.name}`;
},
iconTestClass() {
return `ic-${this.name}`;

View File

@ -90,6 +90,12 @@ const alias = {
// the following resolves files which are different between CE and EE
ee_else_ce: path.join(ROOT_PATH, 'app/assets/javascripts'),
// override loader path for icons.svg so we do not duplicate this asset
'@gitlab/svgs/dist/icons.svg': path.join(
ROOT_PATH,
'app/assets/javascripts/lib/utils/icons_path.js',
),
};
if (IS_EE) {
@ -157,8 +163,16 @@ module.exports = {
exclude: /node_modules/,
loader: 'graphql-tag/loader',
},
{
test: /icons\.svg$/,
loader: 'file-loader',
options: {
name: '[name].[hash:8].[ext]',
},
},
{
test: /\.svg$/,
exclude: /icons\.svg$/,
loader: 'raw-loader',
},
{