var webpack = require('webpack');
var path = require("path");
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var BundleTracker = require('webpack-bundle-tracker');
var BASE = __dirname;
module.exports = {
entry: {
app: [BASE + '/js/index.js']
},
output: {
path: BASE + '/../static/compiled/',
filename: "[name]-[hash].js"
},
plugins: [
new BundleTracker({filename: './webpack-stats.json'}),
new ExtractTextPlugin('stylez.css', { allChunks: true })
],
module: {
noParse: /vendor/,
loaders: [
{
test: /\.js?$/,
loaders: ['babel-loader']
},
{
test: /\.(less|css)?$/,
loader: ExtractTextPlugin.extract("style-loader", "css-loader!less-loader")
},
{
test: /\.json$/,
loader: "json"
},
{
test: /\.csv$/,
loader: "dsv-loader"
},
{
test: /\.(png|jpg|jpeg|gif)/,
loader: 'file-loader'
}
]
}
};
{
"status": "done",
"chunks": {
"app": [{
"name": "bundle.js",
"path": "/Users/eitan/Sites/myApp/static/compiled/bundle.js"
}]
}
}
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static/compiled/')
WEBPACK_LOADER = {
'DEFAULT': {
'BUNDLE_DIR_NAME': 'compiled/',
'STATS_FILE': os.path.join(BASE_DIR, 'frontend/webpack-stats.json')
}
}
<!DOCTYPE html />
<html>
<head>
<meta charset="UTF-8">
<title>
{% if title %} {{ title }} | {% endif %}
{{ site_title|default:_('Lexikon') }}
</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="/static/images/favicon.png">
{% render_bundle 'style' %}
</head>
<body>...</body>
{% render_bundle 'app' %}
</body>
</html>
"webpack-bundle-tracker": "^0.1.0"
.js.gz
or .css.gz
Well. To begin with, this is my webpack-config
:
module.exports = [{
context: __dirname,
entry: {
main: './assets/main/main.js'
},
output: {
path: path.resolve('./assets/bundles/'),
filename: "[name]-[hash].js"
},
plugins: [
new BundleTracker({filename: './webpack-stats.json'})
],
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
query: {
presets: ['es2015']
}
},
{
test: /\.(scss|sass)$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name]-[hash].css',
},
},
{ loader: 'extract-loader' },
{ loader: 'css-loader' },
{
loader: 'sass-loader',
options: {
includePaths: ['./node_modules'],
indentedSyntax: true,
indentType: 'tab'
}
}
]
}
]
}
}];
Yeah, it differs a bit from "standard" configurations when it comes to processing SASS, but ....I think that's okay, right?
Well, I've done almost everything at this moment:
I even get the result, but only the js-file
{% render_bundle 'main' 'css' %}
will return nothing. So I'm just wondering how I could make this thing work @owais