Created
September 19, 2016 07:56
-
-
Save busla/2f562137b9b23c66a5ea61adb1aae0bb to your computer and use it in GitHub Desktop.
Font Awesome for SurviveJS tutorial (npm i font-awesome --save)
This file contains hidden or 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
... | |
exports.loadFonts = function(paths) { | |
return { | |
module: { | |
loaders: [ | |
{ | |
test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, | |
loader: "url", | |
query: { | |
limit: 10000, | |
mimetype: "application/font-woff", | |
name: 'fonts/[hash].[ext]' | |
}, | |
}, | |
{ | |
test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/, | |
loader: "url", | |
query: { | |
limit: 10000, | |
mimetype: "application/font-woff", | |
name: 'fonts/[hash].[ext]' | |
}, | |
}, | |
{ | |
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, | |
loader: "url", | |
query: { | |
limit: 10000, | |
mimetype: "application/octet-stream", | |
name: 'fonts/[hash].[ext]' | |
}, | |
}, | |
{ | |
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, | |
loader: "file", | |
query: { | |
name: 'fonts/[hash].[ext]' | |
}, | |
}, | |
{ | |
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, | |
loader: "url", | |
query: { | |
limit: 10000, | |
mimetype: "image/svg+xml", | |
name: 'fonts/[hash].[ext]' | |
}, | |
} | |
] | |
}, | |
}; | |
} | |
... |
This file contains hidden or 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
... | |
const PATHS = { | |
app: path.join(__dirname, 'app'), | |
style: [ | |
path.join(__dirname, 'node_modules', 'purecss'), | |
// include the font-awesome css in the build | |
path.join(__dirname, 'node_modules', 'font-awesome', 'css', 'font-awesome.min.css') | |
], | |
fonts: path.join(__dirname, 'node_modules', 'font-awesome', 'fonts'), | |
build: path.join(__dirname, 'build') | |
}; | |
... | |
switch(process.env.npm_lifecycle_event) { | |
case 'build': | |
config = merge( | |
common, | |
// merge it into the build | |
parts.loadFonts(PATHS.fonts), | |
... | |
default: | |
config = merge( | |
{ | |
devtool: 'eval-source-map' | |
}, | |
common, | |
// merge it with HMR | |
parts.loadFonts(PATHS.fonts), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment