I am using NodeJs, webpack & ES2015 for my app.
I cannot seem to figure out how to import an image/s in my modules. The following does not work.
import "../../css/image/t1.png";
EDIT: As per Sitian's request, here is my webpack config:
const webpack = require( "webpack" );
const path = require( "path" );
const merge = require( "webpack-merge" );
const TARGET = process.env.npm_lifecycle_event;
process.env.BABEL_ENV = TARGET;
const PATHS = {
app : path.join( __dirname, "app" ),
build : path.join( __dirname, "build" )
};
const common = {
entry : {
app : PATHS.app
},
resolve : { // helps us refer to .js? without ext.
extensions : [ "", ".js", ".jsx" ]
},
output : {
path : PATHS.build,
filename : "bundle.js"
},
module : {
preLoaders : [
{
test : /\.css$/,
loaders : [ "postcss" ],
include : PATHS.app
},
{
test : /\.jsx?$/,
loaders : [ "eslint" ],
include : PATHS.app
}
],
loaders : [
{
test : /\.css$/,
loaders : [ "style", "css" ],
include : PATHS.app
},
{
test : /\.jsx?$/,
loader : 'babel',
query : {
cacheDirectory : true,
presets : [ 'react', 'es2015' ]
},
include : PATHS.app
}
]
}
};
if( TARGET === "start" || !TARGET ) {
module.exports = merge( common, {
devtool : 'inline-source-map',
devServer : {
contentBase : PATHS.build,
hot : true,
progress : true,
stats : 'errors-only'
},
plugins : [
new webpack.HotModuleReplacementPlugin()
]
} );
}
if( TARGET === "build" ) {
module.exports = merge( common, {} );
}