diff options
| author | Adam Soltys <[email protected]> | 2017-01-15 18:24:09 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2017-01-15 18:24:09 -0800 |
| commit | 7762ceaa7e2bb34f8758e17a4c8f512fa6a81b9e (patch) | |
| tree | 91bb1d1b8fe6ad77a48f0e429d9bfd35834c78d9 /build/utils.js | |
| parent | 0ae266bf88f9f79c7e99b272688126898303daa4 (diff) | |
| download | coinos-server-7762ceaa7e2bb34f8758e17a4c8f512fa6a81b9e.tar.gz coinos-server-7762ceaa7e2bb34f8758e17a4c8f512fa6a81b9e.zip | |
Initial Vueification
Diffstat (limited to 'build/utils.js')
| -rw-r--r-- | build/utils.js | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/build/utils.js b/build/utils.js new file mode 100644 index 00000000..dc3cdd01 --- /dev/null +++ b/build/utils.js @@ -0,0 +1,61 @@ +var path = require('path') +var config = require('../config') +var ExtractTextPlugin = require('extract-text-webpack-plugin') + +exports.assetsPath = function (_path) { + var assetsSubDirectory = process.env.NODE_ENV === 'production' + ? config.build.assetsSubDirectory + : config.dev.assetsSubDirectory + return path.posix.join(assetsSubDirectory, _path) +} + +exports.cssLoaders = function (options) { + options = options || {} + // generate loader string to be used with extract text plugin + function generateLoaders (loaders) { + var sourceLoader = loaders.map(function (loader) { + var extraParamChar + if (/\?/.test(loader)) { + loader = loader.replace(/\?/, '-loader?') + extraParamChar = '&' + } else { + loader = loader + '-loader' + extraParamChar = '?' + } + return loader + (options.sourceMap ? extraParamChar + 'sourceMap' : '') + }).join('!') + + // Extract CSS when that option is specified + // (which is the case during production build) + if (options.extract) { + return ExtractTextPlugin.extract('vue-style-loader', sourceLoader) + } else { + return ['vue-style-loader', sourceLoader].join('!') + } + } + + // http://vuejs.github.io/vue-loader/en/configurations/extract-css.html + return { + css: generateLoaders(['css']), + postcss: generateLoaders(['css']), + less: generateLoaders(['css', 'less']), + sass: generateLoaders(['css', 'sass?indentedSyntax']), + scss: generateLoaders(['css', 'sass']), + stylus: generateLoaders(['css', 'stylus']), + styl: generateLoaders(['css', 'stylus']) + } +} + +// Generate loaders for standalone style files (outside of .vue) +exports.styleLoaders = function (options) { + var output = [] + var loaders = exports.cssLoaders(options) + for (var extension in loaders) { + var loader = loaders[extension] + output.push({ + test: new RegExp('\\.' + extension + '$'), + loader: loader + }) + } + return output +} |
