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

Separate CSS file on build #753

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include dash_core_components/dash_core_components.css
include dash_core_components/dash_core_components.min.js
include dash_core_components/dash_core_components.min.js.map
include dash_core_components/dash_core_components-shared.js
Expand Down
10 changes: 9 additions & 1 deletion dash_core_components_base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,13 @@
},
])

_css_dist = [
{
'relative_package_path': '{}.css'.format(__name__),
'namespace': 'dash_core_components',
}
]

for _component in __all__:
setattr(locals()[_component], '_js_dist', _js_dist)
setattr(locals()[_component], '_js_dist', _js_dist)
setattr(locals()[_component], '_css_dist', _css_dist)
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,15 @@
"exec-sh": "^0.3.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^24.5.0",
"mini-css-extract-plugin": "^0.9.0",
"npm-run-all": "^4.1.5",
"optimize-css-assets-webpack-plugin": "^5.0.3",
"prettier": "^1.14.2",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-jsx-parser": "^1.21.0",
"react-resize-detector": "^4.2.1",
"style-loader": "^0.23.1",
"style-loader": "^1.0.0",
"styled-jsx": "^3.1.1",
"terser-webpack-plugin": "^2.3.0",
"webpack": "^4.37.0",
Expand Down
20 changes: 13 additions & 7 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const path = require('path');
const TerserPlugin = require('terser-webpack-plugin');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
const webpack = require('webpack');
const WebpackDashDynamicImport = require('@plotly/webpack-dash-dynamic-import');

Expand Down Expand Up @@ -82,10 +84,10 @@ module.exports = (env, argv) => {
test: /\.css$/,
use: [
{
loader: 'style-loader',
options: {
insertAt: 'top'
}
loader:
mode === "production"
? MiniCssExtractPlugin.loader
: "style-loader",
},
{
loader: 'css-loader',
Expand All @@ -109,7 +111,8 @@ module.exports = (env, argv) => {
warnings: false,
ie8: false
}
})
}),
new OptimizeCSSAssetsPlugin({})
],
splitChunks: {
name: true,
Expand All @@ -131,11 +134,14 @@ module.exports = (env, argv) => {
}
},
plugins: [
new WebpackDashDynamicImport(),
new MiniCssExtractPlugin({
filename: `${dashLibraryName}.css`,
}),
//new WebpackDashDynamicImport(),
Copy link
Author

@anders-kiaer anders-kiaer Feb 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to comment this one out temporarily in order to be able to run npm run build, but I guess someone knowing the details of WebpackDashDynamicImport would be able to figure out how to include it again.

new webpack.SourceMapDevToolPlugin({
filename: '[file].map',
exclude: ['async~plotlyjs']
})
]
}
};
};