Answer the question
In order to leave comments, you need to log in
How to make webpack load files for video tags, video(poster) tags and so on by itself?
config
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const merge = require('webpack-merge');
const webpack = require('webpack');
const pug = require('./webpack_config/pug');
const devserver = require('./webpack_config/devserver');
const sass = require('./webpack_config/sass');
//const compass = require('./webpack_config/compass');
//const resourcesLoader = require('./webpack_config/resources.loader');
const css = require('./webpack_config/css');
const extractCSS = require('./webpack_config/css.extract');
const uglifyJS = require('./webpack_config/uglifyjs');
//babel
const babel = require('./webpack_config/babel');
//const babelLoader = require('./webpack_config/babelLoader');
const typescript = require('./webpack_config/typescript');
//file-loader
const images = require('./webpack_config/images');
const fonts = require('./webpack_config/fonts');
const PATHS = {
source: path.join(__dirname, '_autovep'),
build: path.join(__dirname, '_autovep-build'),
};
const common = merge([
{
entry: {
'index': PATHS.source + '/pages/index/index.js',
/* end */
},
output: {
path: PATHS.build,
filename: './assets/js/[name].js',
library: '[name]',
libraryTarget: 'umd',
libraryExport: 'default',
umdNamedDefine: true,
},
plugins: [
new HtmlWebpackPlugin({
favicon: '_autovep/favicon.png',
filename: 'index.html',
chunks: ['index', 'common'],
template: PATHS.source + '/pages/index/index.pug',
}),
/* end */
new webpack.optimize.CommonsChunkPlugin({
name: 'common'
}),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery'
}),
],
},
pug(),
images(),
fonts(),
]);
module.exports = function(env) {
process.env.mode = env;
if (env === 'production') {
return merge([
common,
extractCSS(),
uglifyJS,
babel,
]);
} else if (env === 'development') {
return merge([
common,
devserver(),
sass(),
//compass(),
//resourcesLoader(),
css(),
babel,
]);
}
};
module.exports = function() {
return {
module: {
rules: [
{
test: /\.(jpg|png|svg|gif|ico)$/,
loader: 'file-loader',
options:
{
name: 'assets/images/[name].[ext]'
},
},
{
test: /\.(mov|mp4)$/,
loader: 'file-loader',
options:
{
name: 'assets/video/[name].[ext]'
},
},
],
},
};
};
/* main */
module.exports = function() {
return {
module: {
rules: [
{
test: /\.pug$/,
use: [
'html-loader',
'pug-html-loader?{"pretty":true,"exports":false}'
],
}
]
}
};
};
img(src='../../images/logo/logo.svg' alt='')
module: {
rules: [
{ test: /\.jpg$/, use: [ "file-loader" ] },
{ test: /\.png$/, use: [ "url-loader?mimetype=image/png" ] }
]
},
var attributes = ["img:src", "source:src", "video:poster"];
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question