Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Commit ad299f6

Browse files
author
Anders Fredrik Kiær
committed
Separate CSS file on build
1 parent 7fa7feb commit ad299f6

File tree

4 files changed

+26
-9
lines changed

4 files changed

+26
-9
lines changed

MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
include dash_core_components/dash_core_components.css
12
include dash_core_components/dash_core_components.min.js
23
include dash_core_components/dash_core_components.min.js.map
34
include dash_core_components/dash_core_components-shared.js

dash_core_components_base/__init__.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -135,5 +135,13 @@
135135
},
136136
])
137137

138+
_css_dist = [
139+
{
140+
'relative_package_path': '{}.css'.format(__name__),
141+
'namespace': 'dash_core_components',
142+
}
143+
]
144+
138145
for _component in __all__:
139-
setattr(locals()[_component], '_js_dist', _js_dist)
146+
setattr(locals()[_component], '_js_dist', _js_dist)
147+
setattr(locals()[_component], '_css_dist', _css_dist)

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,15 @@
7878
"exec-sh": "^0.3.0",
7979
"identity-obj-proxy": "^3.0.0",
8080
"jest": "^24.5.0",
81+
"mini-css-extract-plugin": "^0.9.0",
8182
"npm-run-all": "^4.1.5",
83+
"optimize-css-assets-webpack-plugin": "^5.0.3",
8284
"prettier": "^1.14.2",
8385
"react": "^16.8.6",
8486
"react-dom": "^16.8.6",
8587
"react-jsx-parser": "^1.21.0",
8688
"react-resize-detector": "^4.2.1",
87-
"style-loader": "^0.23.1",
89+
"style-loader": "^1.0.0",
8890
"styled-jsx": "^3.1.1",
8991
"terser-webpack-plugin": "^2.3.0",
9092
"webpack": "^4.37.0",

webpack.config.js

+13-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
const path = require('path');
22
const TerserPlugin = require('terser-webpack-plugin');
3+
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
4+
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
35
const webpack = require('webpack');
46
const WebpackDashDynamicImport = require('@plotly/webpack-dash-dynamic-import');
57

@@ -82,10 +84,10 @@ module.exports = (env, argv) => {
8284
test: /\.css$/,
8385
use: [
8486
{
85-
loader: 'style-loader',
86-
options: {
87-
insertAt: 'top'
88-
}
87+
loader:
88+
mode === "production"
89+
? MiniCssExtractPlugin.loader
90+
: "style-loader",
8991
},
9092
{
9193
loader: 'css-loader',
@@ -109,7 +111,8 @@ module.exports = (env, argv) => {
109111
warnings: false,
110112
ie8: false
111113
}
112-
})
114+
}),
115+
new OptimizeCSSAssetsPlugin({})
113116
],
114117
splitChunks: {
115118
name: true,
@@ -131,11 +134,14 @@ module.exports = (env, argv) => {
131134
}
132135
},
133136
plugins: [
134-
new WebpackDashDynamicImport(),
137+
new MiniCssExtractPlugin({
138+
filename: `${dashLibraryName}.css`,
139+
}),
140+
//new WebpackDashDynamicImport(),
135141
new webpack.SourceMapDevToolPlugin({
136142
filename: '[file].map',
137143
exclude: ['async~plotlyjs']
138144
})
139145
]
140146
}
141-
};
147+
};

0 commit comments

Comments
 (0)