From 986494ac80ae9c6a5cfcd574856e124eb5f97f48 Mon Sep 17 00:00:00 2001 From: Jeff Nusz Date: Thu, 1 Sep 2016 12:50:55 -0700 Subject: [PATCH] tidy up how optional CSS file is built --- package.json | 6 ++++-- src/dat/gui/GUI.js | 5 ++--- src/dat/utils/css.js | 2 +- webpack/webpack.config.js | 5 +++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 6434774..504de42 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,10 @@ }, "scripts": { "test": "node ./node_modules/eslint/bin/eslint.js src/", - "build": "webpack --config ./webpack/webpack.config.js --devtool sourcemap && webpack --config ./webpack/webpack.config.min.js", - "dev": "webpack --progress --colors --watch --config webpack/webpack.config.js --devtool sourcemap" + "dev": "webpack --progress --colors --watch --config webpack/webpack.config.js --devtool sourcemap", + "build": "npm run build-js && npm run build-css", + "build-js": "webpack --config ./webpack/webpack.config.js --devtool sourcemap && webpack --config ./webpack/webpack.config.min.js", + "build-css": "node-sass src/dat/gui/style.scss build/dat.gui.css" }, "repository": { "type": "git", diff --git a/src/dat/gui/GUI.js b/src/dat/gui/GUI.js index d4bf25d..0bbe76d 100644 --- a/src/dat/gui/GUI.js +++ b/src/dat/gui/GUI.js @@ -25,10 +25,9 @@ import CenteredDiv from '../dom/CenteredDiv'; import dom from '../dom/dom'; import common from '../utils/common'; -import styleSheet from '!css!sass!./style.scss'; // CSS to embed in build -import styleSheetExternal from '!file?name=dat.gui.css!extract!css!sass!./style.scss'; // CSS as external file +import styleSheet from './style.scss'; // CSS to embed in build -css.inject(styleSheet, styleSheetExternal); +css.inject(styleSheet); /** Outer-most className for GUI's */ const CSS_NAMESPACE = 'dg'; diff --git a/src/dat/utils/css.js b/src/dat/utils/css.js index e027b69..9a9bc37 100644 --- a/src/dat/utils/css.js +++ b/src/dat/utils/css.js @@ -21,7 +21,7 @@ module.exports = { doc.getElementsByTagName('head')[0].appendChild(link); }, - inject: function(css, externalCssFileName, indoc) { + inject: function(css, indoc) { const doc = indoc || document; const injected = document.createElement('style'); injected.type = 'text/css'; diff --git a/webpack/webpack.config.js b/webpack/webpack.config.js index 68d8c23..83808ed 100644 --- a/webpack/webpack.config.js +++ b/webpack/webpack.config.js @@ -19,7 +19,8 @@ module.exports = { context: path.resolve(__dirname, '..', 'src'), entry: { - main: '../index' + main: '../index', + }, module: { @@ -48,7 +49,7 @@ module.exports = { }, { test: /\.scss$/, - loader: 'style!css!sass' + loader: 'css-loader!sass-loader' } ] },