Files
habitica/webpack/utils.js
Matteo Pagliazzi 4f3a9802c1 Vue Project Setup (#8018)
* add files for new client side and reorg gulp tasks

* add deps and script for new client

* fix webpack paths so that building works

* fix static assets not copied into prod build

* fix linting

* add eslint deps and re-enable it in webpack

* add most missing deps for client side and split .babelrc for client

* reorganize .eslintignore

* update client tests paths and .gitignore

* uncomment code

* client: move App component

* client: update oaths in App component

* fix client tests and add more deps

* add client side tests to npm test

* fix typo in depencency name

* update more deps

* fix karma.conf.js and upgrade phantomjs

* fix dep and move karma.conf to subdirectory

* update karma.conf.js position in Gruntfile

* try downgrading phantomjs

* Fixup client tests (#8032)

* Use phantom 2

* fix(tests): Fix refresher test

* gitignore translation mock

* Update karma version

* disable e2e tests for new client from build

* write vue templates with pug

* add basic routing

* remove unnecessary Function.bind shim

* remove unused dependency
2016-09-18 21:51:20 +02:00

60 lines
1.8 KiB
JavaScript

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('!');
if (options.extract) {
return ExtractTextPlugin.extract('vue-style-loader', sourceLoader);
} else {
return ['vue-style-loader', sourceLoader].join('!');
}
}
// http://vuejs.github.io/vue-loader/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;
};