Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f5359de

Browse files
Adds test for ignore map files
1 parent 1e814c8 commit f5359de

File tree

3 files changed

+58
-1
lines changed

3 files changed

+58
-1
lines changed

‎tests/app/settings.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,10 @@
118118
'CACHE': False,
119119
'BUNDLE_DIR_NAME': 'bundles/',
120120
'STATS_FILE': os.path.join(BASE_DIR, 'webpack-stats-app2.json'),
121-
}
121+
},
122+
'NO_IGNORE': {
123+
'IGNORE': [],
124+
},
122125
}
123126

124127
from django_jinja.builtins import DEFAULT_EXTENSIONS

‎tests/app/tests/test_webpack.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,18 @@ def test_simple_and_css_extract(self):
6767
self.assertEqual(files['main.css']['path'], os.path.join(settings.BASE_DIR, 'assets/bundles/main.css'))
6868
self.assertEqual(files['main.js']['path'], os.path.join(settings.BASE_DIR, 'assets/bundles/main.js'))
6969

70+
def test_default_ignore_config_ignores_map_files(self):
71+
self.compile_bundles('webpack.config.sourcemaps.js')
72+
chunks = get_loader('NO_IGNORE').get_bundle('main')
73+
has_map_files_chunks = any([".map" in chunk["name"] for chunk in chunks])
74+
75+
self.assertTrue(has_map_files_chunks)
76+
77+
chunks = get_loader(DEFAULT_CONFIG).get_bundle('main')
78+
has_map_files_chunks = any([".map" in chunk["name"] for chunk in chunks])
79+
80+
self.assertFalse(has_map_files_chunks)
81+
7082
def test_js_gzip_extract(self):
7183
self.compile_bundles('webpack.config.gzipTest.js')
7284
assets = get_loader(DEFAULT_CONFIG).get_assets()

‎tests/webpack.config.sourcemaps.js‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
var path = require("path");
2+
var webpack = require('webpack');
3+
var BundleTracker = require('webpack-bundle-tracker');
4+
var MiniCssExtractPlugin = require('mini-css-extract-plugin');
5+
6+
7+
module.exports = {
8+
context: __dirname,
9+
entry: './assets/js/index',
10+
devtool: 'source-map',
11+
output: {
12+
path: path.resolve('./assets/bundles/'),
13+
filename: "[name].js"
14+
},
15+
16+
plugins: [
17+
new MiniCssExtractPlugin(),
18+
new BundleTracker({path: __dirname, filename: './webpack-stats.json'}),
19+
],
20+
21+
module: {
22+
rules: [
23+
// we pass the output from babel loader to react-hot loader
24+
{
25+
test: /\.jsx?$/,
26+
exclude: /node_modules/,
27+
use: {
28+
loader: 'babel-loader',
29+
options: {
30+
presets: ['@babel/preset-react']
31+
}
32+
}
33+
},
34+
{ test: /\.css$/, use: [MiniCssExtractPlugin.loader, 'css-loader'], }
35+
],
36+
},
37+
38+
resolve: {
39+
modules: ['node_modules'],
40+
extensions: ['.js', '.jsx']
41+
},
42+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /