Last active
September 20, 2018 16:11
-
-
Save SoldierCorp/ccfbe5871a8a8dedbdf13dc22f8d0161 to your computer and use it in GitHub Desktop.
svg-sprite-loader issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* src/app.js */ | |
// Styles | |
import 'normalize.css'; | |
import 'styles/_app.scss'; | |
$(document).ready(() => { | |
require('scripts/ga-events'); | |
}); | |
// Line to require all the .svg images | |
function requireAll(r) { | |
r.keys().forEach(r); | |
} | |
requireAll(require.context('images/', true, /\.svg$/)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "medal-landing", | |
"version": "0.0.1", | |
"description": "...", | |
"main": "app.js", | |
"license": "MIT", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1", | |
"build": "rimraf dist && webpack --env.NODE_ENV=development --progress", | |
"dev-network": "webpack-dev-server --progress --open --host 0.0.0.0", | |
"dev": "webpack-dev-server --env.NODE_ENV=development --progress --open", | |
"prod": "rimraf dist && webpack --env.NODE_ENV=production -p --progress" | |
}, | |
"devDependencies": { | |
"autoprefixer": "^8.2.0", | |
"babel-core": "^6.26.0", | |
"babel-loader": "^7.1.4", | |
"babel-plugin-module-resolver": "^3.1.0", | |
"babel-preset-env": "^1.6.1", | |
"babel-preset-es2015": "^6.24.1", | |
"copy-webpack-plugin": "^4.5.1", | |
"css-loader": "^0.28.11", | |
"eslint": "^4.19.1", | |
"extract-text-webpack-plugin": "^3.0.2", | |
"file-loader": "^1.1.11", | |
"html-webpack-plugin": "^3.1.0", | |
"node-sass": "^4.7.2", | |
"postcss": "^6.0.21", | |
"postcss-cssnext": "^3.1.0", | |
"postcss-import": "^11.1.0", | |
"postcss-loader": "^2.1.3", | |
"postcss-modules": "^1.1.0", | |
"pug": "^2.0.3", | |
"pug-loader": "^2.3.0", | |
"rimraf": "^2.6.2", | |
"sass-loader": "^6.0.7", | |
"style-loader": "^0.20.3", | |
"svg-sprite-loader": "^3.9.2", | |
"svgo": "^1.1.1", | |
"svgo-loader": "^2.2.0", | |
"tslib": "^1.9.0", | |
"url-loader": "^1.0.1", | |
"webpack": "3.x.x", | |
"webpack-cli": "^3.0.8", | |
"webpack-dev-server": "2.x.x", | |
"webpack-notifier": "^1.6.0" | |
}, | |
"dependencies": { | |
"@fancyapps/fancybox": "^3.3.5", | |
"annyang": "^2.6.0", | |
"bodymovin": "^4.13.0", | |
"bowser": "^1.9.3", | |
"gsap": "^1.20.4", | |
"jquery": "^3.3.1", | |
"lottie-web": "^5.2.0", | |
"normalize.css": "^8.0.0", | |
"scrollmagic": "^2.0.5", | |
"slick-carousel": "^1.8.1" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Libraries | |
*/ | |
const path = require('path'); | |
const webpack = require('webpack'); | |
const ExtractTextPlugin = require('extract-text-webpack-plugin'); | |
const HtmlWebpackPlugin = require('html-webpack-plugin'); | |
const WebpackNotifierPlugin = require('webpack-notifier'); | |
const CopyWebpackPlugin = require('copy-webpack-plugin'); | |
const plugins = require('./postcss.config'); | |
let extractHtml = new ExtractTextPlugin('[name].html') | |
const SpriteLoaderPlugin = require('svg-sprite-loader/plugin'); | |
const vesion = require('./src/config/version.js'); | |
/* | |
Configuration | |
*/ | |
module.exports = env => { | |
return { | |
context: path.resolve(__dirname, './src'), | |
entry: { | |
app: './app.js' | |
}, | |
output: { | |
path: path.resolve(__dirname, './dist'), | |
publicPath: '/', | |
filename: 'assets/js/[name].bundle.js?v=' + '[hash:7]' | |
}, | |
devServer: { | |
contentBase: path.resolve(__dirname, './src'), | |
// hot: true, | |
}, | |
resolve: { | |
extensions: ['.js'], | |
alias: { | |
source: path.resolve(__dirname, './src'), // Relative path of src | |
images: path.resolve(__dirname, './src/assets/images'), // Relative path of images | |
'debug.addIndicators': path.resolve('node_modules', 'scrollmagic/scrollmagic/uncompressed/plugins/debug.addIndicators.js') | |
} | |
}, | |
/* | |
Loaders with their configurations | |
*/ | |
module: { | |
rules: [ | |
{ | |
test: /\.js$/, | |
exclude: [/node_modules/], | |
use: [ | |
{ | |
loader: 'babel-loader', | |
options: { presets: ['es2015'] } | |
} | |
] | |
}, | |
{ | |
test: /\.css$/, | |
use: ExtractTextPlugin.extract({ | |
fallback: 'style-loader', | |
use: [ | |
{ | |
loader: 'css-loader', | |
options: { | |
importLoaders: 1, | |
sourceMap: true, | |
minimize: true, | |
colormin: false | |
} | |
}, | |
] | |
}) | |
}, | |
{ | |
use: 'css-loader!sass-loader?sourceMap', | |
test: /\.(sass|scss)$/, | |
use: ExtractTextPlugin.extract({ | |
fallback: 'style-loader', | |
use: [ | |
{ | |
loader: 'css-loader', | |
options: { | |
importLoaders: 1, | |
sourceMap: true, | |
minimize: true, | |
colormin: false | |
} | |
}, | |
{ | |
loader: 'postcss-loader', | |
options: { | |
sourceMap: true, | |
minimize: true, | |
colormin: false | |
} | |
}, | |
'sass-loader?sourceMap' | |
] | |
}) | |
}, | |
{ | |
test: /\.pug$/, | |
use: [ | |
{ | |
loader: 'pug-loader' | |
} | |
] | |
}, | |
{ | |
test: /\.(png|jpe?g|gif|svg|ico)(\?.*)?$/, | |
loader: 'url-loader', | |
options: { | |
limit: 512, | |
name: 'assets/images/[name].[ext]?v=' + '[hash:7]', | |
} | |
}, | |
{ | |
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, | |
loader: 'url-loader', | |
options: { | |
limit: 512, | |
name: 'assets/fonts/[name].[ext]?v=' + '[hash:7]', | |
} | |
}, | |
{ | |
test: /\.(mp4)(\?.*)?$/, | |
loader: 'url-loader', | |
options: { | |
limit: 512, | |
name: 'assets/videos/[name].[ext]?v=' + '[hash:7]', | |
} | |
}, | |
{ | |
test: /\.svg$/, | |
use: [ | |
'svg-sprite-loader', | |
'svgo-loader' | |
] | |
// use: [ | |
// { loader: 'svg-sprite-loader', | |
// options: { | |
// extract: true, | |
// spriteFilename: svgPath => `assets/images/sprite${svgPath.substr(-4)}` | |
// } | |
// }, | |
// 'svgo-loader' | |
// ], | |
// } | |
] | |
}, | |
plugins: [ | |
new CopyWebpackPlugin([ | |
{ from: '../manifest.json', to: 'manifest.json' }, | |
{ from: '../browserconfig.xml', to: 'browserconfig.xml' }, | |
{ from: 'assets/images/favicons/android-chrome-192x192.png', to: 'assets/images/android-chrome-192x192.png' }, | |
{ from: 'assets/images/favicons/android-chrome-256x256.png', to: 'assets/images/android-chrome-256x256.png' }, | |
{ from: 'assets/images/favicons/mstile-150x150.png', to: 'assets/images/mstile-150x150.png' }, | |
{ from: 'assets/images/animation/animation.json', to: 'assets/images/animation/animation.json' } | |
]), | |
new ExtractTextPlugin({ | |
filename: 'assets/css/[name].bundle.css?v=' + '[hash:7]', | |
allChunks: true | |
}), | |
new webpack.optimize.CommonsChunkPlugin({ | |
name: 'vendor' | |
}), | |
/* | |
Pages | |
*/ | |
// Landing page | |
new HtmlWebpackPlugin({ | |
filename: 'index.html', | |
template: 'views/index.pug', | |
inject: true | |
}), | |
new webpack.ProvidePlugin({ | |
$: 'jquery', | |
jQuery: 'jquery', | |
'window.$': 'jquery', | |
'window.jQuery': 'jquery' | |
}), | |
new SpriteLoaderPlugin(), | |
] | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment