1
0
mirror of https://github.com/yldio/copilot.git synced 2024-12-01 07:30:07 +02:00

fix .css loading in tests

This commit is contained in:
Sérgio Ramos 2016-10-24 12:23:05 +01:00
parent 08f56bb30a
commit 7412d28277
5 changed files with 164 additions and 36 deletions

View File

@ -29,7 +29,11 @@
"polyfill": false, "polyfill": false,
"regenerator": false "regenerator": false
} }
] ],
["babel-plugin-webpack-loaders", {
"config": "${CONFIG}",
"verbose": true
}]
] ]
} }
} }

View File

@ -11,7 +11,7 @@
"scripts": { "scripts": {
"start": "webpack-dev-server --open --config webpack/index.js", "start": "webpack-dev-server --open --config webpack/index.js",
"lint": "eslint .", "lint": "eslint .",
"test": "NODE_ENV=test nyc ava test/*.js --verbose", "test": "BABEL_DISABLE_CACHE=1 NODE_ENV=test CONFIG=$(pwd)/webpack/index.js nyc ava test/*.js --verbose",
"open": "nyc report --reporter=html & open coverage/index.html", "open": "nyc report --reporter=html & open coverage/index.html",
"coverage": "nyc check-coverage --statements 100 --functions 100 --lines 100 --branches 100", "coverage": "nyc check-coverage --statements 100 --functions 100 --lines 100 --branches 100",
"build-locales": "NODE_ENV=test babel-node scripts/build-locales" "build-locales": "NODE_ENV=test babel-node scripts/build-locales"
@ -46,6 +46,7 @@
"babel-plugin-transform-es2015-modules-commonjs": "^6.16.0", "babel-plugin-transform-es2015-modules-commonjs": "^6.16.0",
"babel-plugin-transform-object-rest-spread": "^6.16.0", "babel-plugin-transform-object-rest-spread": "^6.16.0",
"babel-plugin-transform-runtime": "^6.15.0", "babel-plugin-transform-runtime": "^6.15.0",
"babel-plugin-webpack-loaders": "^0.8.0",
"babel-preset-react": "^6.16.0", "babel-preset-react": "^6.16.0",
"babel-register": "^6.16.3", "babel-register": "^6.16.3",
"css-loader": "^0.25.0", "css-loader": "^0.25.0",

View File

@ -4,20 +4,13 @@ const webpack = require('webpack');
const WebpackShellPlugin = require('webpack-shell-plugin'); const WebpackShellPlugin = require('webpack-shell-plugin');
const path = require('path'); const path = require('path');
module.exports = { const plugins = {
context: path.join(__dirname, '../src'), 'no-errors-plugin': new webpack.NoErrorsPlugin(),
output: { 'extract-text-plugin': new ExtractTextPlugin({
path: path.join(__dirname, '../static'),
publicPath: '/static/',
filename: 'bundle.js'
},
plugins: [
new webpack.NoErrorsPlugin(),
new ExtractTextPlugin({
filename: 'bundle.css', filename: 'bundle.css',
allChunks: true allChunks: true
}), }),
new webpack.LoaderOptionsPlugin({ 'loader-options-plugin': new webpack.LoaderOptionsPlugin({
options: { options: {
postcss: { postcss: {
plugins: () => { plugins: () => {
@ -28,16 +21,31 @@ module.exports = {
} }
} }
}), }),
new webpack.DefinePlugin({ 'define-plugin': new webpack.DefinePlugin({
'process.env': { 'process.env': {
NODE_ENV: JSON.stringify(process.env['NODE_ENV'] || 'development'), NODE_ENV: JSON.stringify(process.env['NODE_ENV'] || 'development'),
APP_NAME: JSON.stringify(pkg.name), APP_NAME: JSON.stringify(pkg.name),
APP_VERSION: JSON.stringify(pkg.version) APP_VERSION: JSON.stringify(pkg.version)
} }
}), }),
new WebpackShellPlugin({ 'shell-plugin': new WebpackShellPlugin({
onBuildStart: ['npm run build-locales'] onBuildStart: ['npm run build-locales']
}) })
};
module.exports = {
context: path.join(__dirname, '../src'),
output: {
path: path.join(__dirname, '../static'),
publicPath: '/static/',
filename: 'bundle.js'
},
plugins: [
plugins['no-errors-plugin'],
plugins['extract-text-plugin'],
plugins['loader-options-plugin'],
plugins['define-plugin'],
plugins['shell-plugin']
], ],
module: { module: {
loaders: [{ loaders: [{
@ -67,3 +75,5 @@ module.exports = {
}] }]
} }
}; };
module.exports.__plugins = plugins;

37
frontend/webpack/test.js Normal file
View File

@ -0,0 +1,37 @@
const config = require('./config');
const webpack = require('webpack');
const path = require('path');
module.exports = {
output: {
libraryTarget: 'commonjs2',
},
plugins: [
config.__plugins['no-errors-plugin'],
config.__plugins['loader-options-plugin'],
config.__plugins['define-plugin']
],
module: {
loaders: [{
test: /\.css?$/,
loader: [
'style-loader', {
loader: 'css-loader',
options: {
modules: true,
importLoaders: 1
}
}, {
loader: 'postcss-loader',
options: {
plugins: function() {
return [
require('postcss-cssnext')
];
}
}
}
]
}]
}
};

View File

@ -590,6 +590,10 @@ babel-plugin-syntax-async-generators@^6.5.0:
version "6.13.0" version "6.13.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-async-generators/-/babel-plugin-syntax-async-generators-6.13.0.tgz#6bc963ebb16eccbae6b92b596eb7f35c342a8b9a" resolved "https://registry.yarnpkg.com/babel-plugin-syntax-async-generators/-/babel-plugin-syntax-async-generators-6.13.0.tgz#6bc963ebb16eccbae6b92b596eb7f35c342a8b9a"
babel-plugin-syntax-class-constructor-call@^6.8.0:
version "6.13.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-class-constructor-call/-/babel-plugin-syntax-class-constructor-call-6.13.0.tgz#96fb2e9f177dca22824065de4392f2fe3486b765"
babel-plugin-syntax-class-properties@^6.8.0: babel-plugin-syntax-class-properties@^6.8.0:
version "6.13.0" version "6.13.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-class-properties/-/babel-plugin-syntax-class-properties-6.13.0.tgz#d7eb23b79a317f8543962c505b827c7d6cac27de" resolved "https://registry.yarnpkg.com/babel-plugin-syntax-class-properties/-/babel-plugin-syntax-class-properties-6.13.0.tgz#d7eb23b79a317f8543962c505b827c7d6cac27de"
@ -598,14 +602,26 @@ babel-plugin-syntax-decorators@^6.13.0:
version "6.13.0" version "6.13.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-decorators/-/babel-plugin-syntax-decorators-6.13.0.tgz#312563b4dbde3cc806cee3e416cceeaddd11ac0b" resolved "https://registry.yarnpkg.com/babel-plugin-syntax-decorators/-/babel-plugin-syntax-decorators-6.13.0.tgz#312563b4dbde3cc806cee3e416cceeaddd11ac0b"
babel-plugin-syntax-do-expressions@^6.8.0:
version "6.13.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-do-expressions/-/babel-plugin-syntax-do-expressions-6.13.0.tgz#5747756139aa26d390d09410b03744ba07e4796d"
babel-plugin-syntax-exponentiation-operator@^6.8.0: babel-plugin-syntax-exponentiation-operator@^6.8.0:
version "6.13.0" version "6.13.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-exponentiation-operator/-/babel-plugin-syntax-exponentiation-operator-6.13.0.tgz#9ee7e8337290da95288201a6a57f4170317830de" resolved "https://registry.yarnpkg.com/babel-plugin-syntax-exponentiation-operator/-/babel-plugin-syntax-exponentiation-operator-6.13.0.tgz#9ee7e8337290da95288201a6a57f4170317830de"
babel-plugin-syntax-export-extensions@^6.8.0:
version "6.13.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-export-extensions/-/babel-plugin-syntax-export-extensions-6.13.0.tgz#70a1484f0f9089a4e84ad44bac353c95b9b12721"
babel-plugin-syntax-flow@^6.3.13, babel-plugin-syntax-flow@^6.8.0: babel-plugin-syntax-flow@^6.3.13, babel-plugin-syntax-flow@^6.8.0:
version "6.13.0" version "6.13.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-flow/-/babel-plugin-syntax-flow-6.13.0.tgz#9af0cd396087bf7677053e1afa52f206c0416f17" resolved "https://registry.yarnpkg.com/babel-plugin-syntax-flow/-/babel-plugin-syntax-flow-6.13.0.tgz#9af0cd396087bf7677053e1afa52f206c0416f17"
babel-plugin-syntax-function-bind@^6.8.0:
version "6.13.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-function-bind/-/babel-plugin-syntax-function-bind-6.13.0.tgz#48c495f177bdf31a981e732f55adc0bdd2601f46"
babel-plugin-syntax-jsx@^6.3.13, babel-plugin-syntax-jsx@^6.8.0: babel-plugin-syntax-jsx@^6.3.13, babel-plugin-syntax-jsx@^6.8.0:
version "6.13.0" version "6.13.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-jsx/-/babel-plugin-syntax-jsx-6.13.0.tgz#e741ff3992c578310be45c571bcd90a2f9c5586e" resolved "https://registry.yarnpkg.com/babel-plugin-syntax-jsx/-/babel-plugin-syntax-jsx-6.13.0.tgz#e741ff3992c578310be45c571bcd90a2f9c5586e"
@ -634,6 +650,14 @@ babel-plugin-transform-async-to-generator@^6.16.0:
babel-plugin-syntax-async-functions "^6.8.0" babel-plugin-syntax-async-functions "^6.8.0"
babel-runtime "^6.0.0" babel-runtime "^6.0.0"
babel-plugin-transform-class-constructor-call@^6.3.13:
version "6.8.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-class-constructor-call/-/babel-plugin-transform-class-constructor-call-6.8.0.tgz#6e740bc80f16d295fa598d92518666020a906192"
dependencies:
babel-plugin-syntax-class-constructor-call "^6.8.0"
babel-runtime "^6.0.0"
babel-template "^6.8.0"
babel-plugin-transform-class-properties@^6.16.0: babel-plugin-transform-class-properties@^6.16.0:
version "6.16.0" version "6.16.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-class-properties/-/babel-plugin-transform-class-properties-6.16.0.tgz#969bca24d34e401d214f36b8af5c1346859bc904" resolved "https://registry.yarnpkg.com/babel-plugin-transform-class-properties/-/babel-plugin-transform-class-properties-6.16.0.tgz#969bca24d34e401d214f36b8af5c1346859bc904"
@ -653,6 +677,13 @@ babel-plugin-transform-decorators@^6.13.0:
babel-template "^6.8.0" babel-template "^6.8.0"
babel-types "^6.13.0" babel-types "^6.13.0"
babel-plugin-transform-do-expressions@^6.3.13:
version "6.8.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-do-expressions/-/babel-plugin-transform-do-expressions-6.8.0.tgz#fda692af339835cc255bb7544efb8f7c1306c273"
dependencies:
babel-plugin-syntax-do-expressions "^6.8.0"
babel-runtime "^6.0.0"
babel-plugin-transform-es2015-arrow-functions@^6.3.13: babel-plugin-transform-es2015-arrow-functions@^6.3.13:
version "6.8.0" version "6.8.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.8.0.tgz#5b63afc3181bdc9a8c4d481b5a4f3f7d7fef3d9d" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.8.0.tgz#5b63afc3181bdc9a8c4d481b5a4f3f7d7fef3d9d"
@ -830,6 +861,13 @@ babel-plugin-transform-exponentiation-operator@^6.3.13:
babel-plugin-syntax-exponentiation-operator "^6.8.0" babel-plugin-syntax-exponentiation-operator "^6.8.0"
babel-runtime "^6.0.0" babel-runtime "^6.0.0"
babel-plugin-transform-export-extensions@^6.3.13:
version "6.8.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-export-extensions/-/babel-plugin-transform-export-extensions-6.8.0.tgz#fa80ff655b636549431bfd38f6b817bd82e47f5b"
dependencies:
babel-plugin-syntax-export-extensions "^6.8.0"
babel-runtime "^6.0.0"
babel-plugin-transform-flow-strip-types@^6.3.13: babel-plugin-transform-flow-strip-types@^6.3.13:
version "6.14.0" version "6.14.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-flow-strip-types/-/babel-plugin-transform-flow-strip-types-6.14.0.tgz#35ceb03f8770934044bab1a76f7e4ee0aa9220f9" resolved "https://registry.yarnpkg.com/babel-plugin-transform-flow-strip-types/-/babel-plugin-transform-flow-strip-types-6.14.0.tgz#35ceb03f8770934044bab1a76f7e4ee0aa9220f9"
@ -837,6 +875,13 @@ babel-plugin-transform-flow-strip-types@^6.3.13:
babel-plugin-syntax-flow "^6.8.0" babel-plugin-syntax-flow "^6.8.0"
babel-runtime "^6.0.0" babel-runtime "^6.0.0"
babel-plugin-transform-function-bind@^6.3.13:
version "6.8.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-function-bind/-/babel-plugin-transform-function-bind-6.8.0.tgz#e7f334ce69f50d28fe850a822eaaab9fa4f4d821"
dependencies:
babel-plugin-syntax-function-bind "^6.8.0"
babel-runtime "^6.0.0"
babel-plugin-transform-object-rest-spread@^6.16.0: babel-plugin-transform-object-rest-spread@^6.16.0:
version "6.16.0" version "6.16.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-object-rest-spread/-/babel-plugin-transform-object-rest-spread-6.16.0.tgz#db441d56fffc1999052fdebe2e2f25ebd28e36a9" resolved "https://registry.yarnpkg.com/babel-plugin-transform-object-rest-spread/-/babel-plugin-transform-object-rest-spread-6.16.0.tgz#db441d56fffc1999052fdebe2e2f25ebd28e36a9"
@ -893,6 +938,21 @@ babel-plugin-transform-strict-mode@^6.8.0:
babel-runtime "^6.0.0" babel-runtime "^6.0.0"
babel-types "^6.8.0" babel-types "^6.8.0"
babel-plugin-webpack-loaders:
version "0.8.0"
resolved "https://registry.yarnpkg.com/babel-plugin-webpack-loaders/-/babel-plugin-webpack-loaders-0.8.0.tgz#1ec5255e2c9de8d5226c58a099890d935a876065"
dependencies:
babel-preset-es2015 "^6.3.13"
babel-preset-stage-0 "^6.5.0"
babel-register "^6.4.3"
babel-traverse "^6.3.26"
babel-types "^6.3.24"
babylon "^6.3.26"
colors "^1.1.2"
enhanced-resolve "^2.2.2"
lodash "^4.6.1"
rimraf "^2.5.0"
babel-polyfill@^6.16.0: babel-polyfill@^6.16.0:
version "6.16.0" version "6.16.0"
resolved "https://registry.yarnpkg.com/babel-polyfill/-/babel-polyfill-6.16.0.tgz#2d45021df87e26a374b6d4d1a9c65964d17f2422" resolved "https://registry.yarnpkg.com/babel-polyfill/-/babel-polyfill-6.16.0.tgz#2d45021df87e26a374b6d4d1a9c65964d17f2422"
@ -942,7 +1002,23 @@ babel-preset-react@^6.16.0:
babel-plugin-transform-react-jsx-self "^6.11.0" babel-plugin-transform-react-jsx-self "^6.11.0"
babel-plugin-transform-react-jsx-source "^6.3.13" babel-plugin-transform-react-jsx-source "^6.3.13"
babel-preset-stage-2@^6.3.13: babel-preset-stage-0@^6.5.0:
version "6.16.0"
resolved "https://registry.yarnpkg.com/babel-preset-stage-0/-/babel-preset-stage-0-6.16.0.tgz#f5a263c420532fd57491f1a7315b3036e428f823"
dependencies:
babel-plugin-transform-do-expressions "^6.3.13"
babel-plugin-transform-function-bind "^6.3.13"
babel-preset-stage-1 "^6.16.0"
babel-preset-stage-1@^6.16.0:
version "6.16.0"
resolved "https://registry.yarnpkg.com/babel-preset-stage-1/-/babel-preset-stage-1-6.16.0.tgz#9d31fbbdae7b17c549fd3ac93e3cf6902695e479"
dependencies:
babel-plugin-transform-class-constructor-call "^6.3.13"
babel-plugin-transform-export-extensions "^6.3.13"
babel-preset-stage-2 "^6.16.0"
babel-preset-stage-2@^6.16.0, babel-preset-stage-2@^6.3.13:
version "6.17.0" version "6.17.0"
resolved "https://registry.yarnpkg.com/babel-preset-stage-2/-/babel-preset-stage-2-6.17.0.tgz#dc4f84582781353cef36c41247eae5e36c4cae0d" resolved "https://registry.yarnpkg.com/babel-preset-stage-2/-/babel-preset-stage-2-6.17.0.tgz#dc4f84582781353cef36c41247eae5e36c4cae0d"
dependencies: dependencies:
@ -960,7 +1036,7 @@ babel-preset-stage-3@^6.17.0:
babel-plugin-transform-exponentiation-operator "^6.3.13" babel-plugin-transform-exponentiation-operator "^6.3.13"
babel-plugin-transform-object-rest-spread "^6.16.0" babel-plugin-transform-object-rest-spread "^6.16.0"
babel-register@^6.16.0, babel-register@^6.16.3: babel-register@^6.16.0, babel-register@^6.16.3, babel-register@^6.4.3:
version "6.16.3" version "6.16.3"
resolved "https://registry.yarnpkg.com/babel-register/-/babel-register-6.16.3.tgz#7b0c0ca7bfdeb9188ba4c27e5fcb7599a497c624" resolved "https://registry.yarnpkg.com/babel-register/-/babel-register-6.16.3.tgz#7b0c0ca7bfdeb9188ba4c27e5fcb7599a497c624"
dependencies: dependencies:
@ -990,7 +1066,7 @@ babel-template@^6.14.0, babel-template@^6.15.0, babel-template@^6.16.0, babel-te
babylon "^6.11.0" babylon "^6.11.0"
lodash "^4.2.0" lodash "^4.2.0"
babel-traverse@^6.14.0, babel-traverse@^6.15.0, babel-traverse@^6.16.0, babel-traverse@^6.8.0, babel-traverse@^6.9.0: babel-traverse@^6.14.0, babel-traverse@^6.15.0, babel-traverse@^6.16.0, babel-traverse@^6.3.26, babel-traverse@^6.8.0, babel-traverse@^6.9.0:
version "6.16.0" version "6.16.0"
resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.16.0.tgz#fba85ae1fd4d107de9ce003149cc57f53bef0c4f" resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.16.0.tgz#fba85ae1fd4d107de9ce003149cc57f53bef0c4f"
dependencies: dependencies:
@ -1004,7 +1080,7 @@ babel-traverse@^6.14.0, babel-traverse@^6.15.0, babel-traverse@^6.16.0, babel-tr
invariant "^2.2.0" invariant "^2.2.0"
lodash "^4.2.0" lodash "^4.2.0"
babel-types@^6.10.2, babel-types@^6.13.0, babel-types@^6.14.0, babel-types@^6.15.0, babel-types@^6.16.0, babel-types@^6.7.2, babel-types@^6.8.0, babel-types@^6.9.0: babel-types@^6.10.2, babel-types@^6.13.0, babel-types@^6.14.0, babel-types@^6.15.0, babel-types@^6.16.0, babel-types@^6.3.24, babel-types@^6.7.2, babel-types@^6.8.0, babel-types@^6.9.0:
version "6.16.0" version "6.16.0"
resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.16.0.tgz#71cca1dbe5337766225c5c193071e8ebcbcffcfe" resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.16.0.tgz#71cca1dbe5337766225c5c193071e8ebcbcffcfe"
dependencies: dependencies:
@ -1013,7 +1089,7 @@ babel-types@^6.10.2, babel-types@^6.13.0, babel-types@^6.14.0, babel-types@^6.15
lodash "^4.2.0" lodash "^4.2.0"
to-fast-properties "^1.0.1" to-fast-properties "^1.0.1"
babylon@^6.1.0, babylon@^6.11.0, babylon@^6.11.2, babylon@^6.8.1: babylon@^6.1.0, babylon@^6.11.0, babylon@^6.11.2, babylon@^6.3.26, babylon@^6.8.1:
version "6.13.0" version "6.13.0"
resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.13.0.tgz#58ed40dd2a8120612be5f318c2c0bedbebde4a0b" resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.13.0.tgz#58ed40dd2a8120612be5f318c2c0bedbebde4a0b"
@ -1521,7 +1597,7 @@ colormin@^1.0.5:
css-color-names "0.0.4" css-color-names "0.0.4"
has "^1.0.1" has "^1.0.1"
colors@~1.1.2: colors@^1.1.2, colors@~1.1.2:
version "1.1.2" version "1.1.2"
resolved "https://registry.yarnpkg.com/colors/-/colors-1.1.2.tgz#168a4701756b6a7f51a12ce0c97bfa28c084ed63" resolved "https://registry.yarnpkg.com/colors/-/colors-1.1.2.tgz#168a4701756b6a7f51a12ce0c97bfa28c084ed63"
@ -2057,7 +2133,7 @@ encoding@^0.1.11:
dependencies: dependencies:
iconv-lite "~0.4.13" iconv-lite "~0.4.13"
enhanced-resolve@^2.2.0: enhanced-resolve@^2.2.0, enhanced-resolve@^2.2.2:
version "2.3.0" version "2.3.0"
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-2.3.0.tgz#a115c32504b6302e85a76269d7a57ccdd962e359" resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-2.3.0.tgz#a115c32504b6302e85a76269d7a57ccdd962e359"
dependencies: dependencies:
@ -5281,7 +5357,7 @@ right-align@^0.1.1:
dependencies: dependencies:
align-text "^0.1.1" align-text "^0.1.1"
rimraf@^2.2.8, rimraf@^2.3.3, rimraf@^2.4.3, rimraf@^2.4.4, rimraf@^2.5.4, rimraf@~2.5.0, rimraf@~2.5.1, rimraf@2: rimraf@^2.2.8, rimraf@^2.3.3, rimraf@^2.4.3, rimraf@^2.4.4, rimraf@^2.5.0, rimraf@^2.5.4, rimraf@~2.5.0, rimraf@~2.5.1, rimraf@2:
version "2.5.4" version "2.5.4"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.5.4.tgz#96800093cbf1a0c86bd95b4625467535c29dfa04" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.5.4.tgz#96800093cbf1a0c86bd95b4625467535c29dfa04"
dependencies: dependencies: