By Julien Tanguy
import stylesheet from 'styles/my-styles.scss';
import logo from 'img/my-logo.svg';
import someTemplate from 'html/some-template.html';
console.log(stylesheet);
//"body{font-size:12px}"
console.log(logo);
//"data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5[...]"
console.log(someTemplate);
//"<html><body><h1>Hello</h1></body></html>"
json, raw, xml, dsv, yaml...
file, url, image, uglify, vue, s3...
coffee, babel, ts, purs, elm, ion...
html, pug, jsx, mustache, swig...
css, less, sass, stylus, postcss...
po, format, properties, gettext...
mocha, istambul, eslint, standard...
environment, commonsChunk, define, s3...
//static imports
import _ from 'lodash'
// dynamic imports
require.ensure([], function(require) {
const d3 = require('d3')
//do d3 stuff
})
module.exports = {
entry: { /* Entry points */ },
resolve: { /* File resolver */ },
output: { /* Output config*/ },
devServer: { /**/ },
module: {
loaders: [ /* loaders */ ],
plugins: [ /* plugins */ ]
}
entry: {
bundle: "./src/index.js",
},
resolve: {
extensions: ["", ".js", ".jsx", ".css", ".scss"]
},
output: {
path: path.join(__dirname, 'dist'),
filename: "[name].js",
},
devServer: {
outputPath: path.join(__dirname, 'dist')
},
{
test: /\.scss|\.css$/,
loader: "style!css!sass"
},
{
test: /\.js/,
exclude: /(node_modules|bower_components)/,
loader: "babel",
query: {
presets: ["es2015"]
}
},
{
test: /\.png|\.svg|\.jpg$/,
loader: "url-loader",
query: {
limit: 100000 /*100 kb*/
}
},
new webpack.DefinePlugin({
__DEVELOPMENT__: JSON.stringify(
process.env.NODE_ENV === 'development' )
}),
new HtmlWebpackPlugin({
title: 'My application',
appMountId: 'app',
inject: false,
template: path.join(__dirname, 'assets', 'index.html')
})