Build working

This commit is contained in:
Pierre Burgy 2016-11-18 16:18:29 +01:00
parent 25ced3c084
commit 79ba29b6a1
16 changed files with 79 additions and 36 deletions

View File

@ -38,7 +38,9 @@ module.exports = {
},
file: function* () {
console.log('file', this.params.file, ' ', path.resolve(__dirname, '..', 'public', 'build', this.params.file));
yield sendfile(this, path.resolve(__dirname, '..', 'public', 'build', this.params.file));
console.log(':(')
if (!this.status) this.throw(404);
}
};

View File

@ -45,7 +45,7 @@ if (module.hot) {
module.hot.accept('./i18n', () => {
if (window.Strapi) {
System.import('./i18n')
.then(result => {
.then((result) => {
const translationMessagesUpdated = result.translationMessages;
window.Strapi.refresh(pluginId).translationMessages(translationMessagesUpdated);
});

View File

@ -13,19 +13,18 @@ import { injectIntl, intlShape, FormattedMessage } from 'react-intl';
import appMessages from 'containers/App/messages.json';
import messages from './messages.json';
console.log('messages', messages)
import { define } from '../../i18n';
define(messages);
import {
selectHome,
// selectHome,
selectLoading,
selectError,
selectGeneralSettings,
// selectGeneralSettings,
selectName,
selectDescription,
selectVersion,
selectLocationState,
// selectLocationState,
} from './selectors';
import {
@ -124,17 +123,17 @@ HomePage.propTypes = {
React.PropTypes.string,
React.PropTypes.bool,
]),
error: React.PropTypes.oneOfType([
React.PropTypes.object,
React.PropTypes.bool,
]),
// error: React.PropTypes.oneOfType([
// React.PropTypes.object,
// React.PropTypes.bool,
// ]),
intl: intlShape.isRequired,
loading: React.PropTypes.bool,
// loading: React.PropTypes.bool,
name: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.bool,
]),
onCancel: React.PropTypes.func,
// onCancel: React.PropTypes.func,
onChangeName: React.PropTypes.func,
onChangeDescription: React.PropTypes.func,
onChangeVersion: React.PropTypes.func,

View File

@ -15,7 +15,7 @@ const translationMessages = {
fr: frTranslationMessages,
};
const define = messages => {
const define = (messages) => {
defineMessages(messages);
};

View File

@ -9,7 +9,7 @@ import createSagaMiddleware from 'redux-saga';
import createReducer from './reducers';
const sagaMiddleware = createSagaMiddleware();
const devtools = window.devToolsExtension || (() => noop => noop);
const devtools = window.devToolsExtension || (() => (noop) => noop);
export default function configureStore(initialState = {}, history) {
// Create the store with two middlewares

View File

@ -19,13 +19,13 @@ function parseJSON(response) {
* @return {Promise} Returns either the response, or throws an error
*/
function checkStatus(response) {
return new Promise(resolve => {
return new Promise((resolve) => {
if (response.status >= 200 && response.status < 300) {
return resolve(response);
}
return parseJSON(response)
.then(data => {
.then((data) => {
const error = new Error(data.message || response.statusText);
error.data = data;
error.response = response;

View File

@ -3,7 +3,7 @@
*/
import expect from 'expect';
import configureStore from 'store.js';
import configureStore from 'store';
import { memoryHistory } from 'react-router';
import { put } from 'redux-saga/effects';
import { fromJS } from 'immutable';

View File

@ -17,7 +17,7 @@ module.exports = {
name: 'name',
message: 'What should it be called?',
default: 'Button',
validate: value => {
validate: (value) => {
if ((/.+/).test(value)) {
return componentExists(value) ? 'A component or container with this name already exists' : true;
}
@ -35,7 +35,7 @@ module.exports = {
default: true,
message: 'Do you want i18n messages (i.e. will this component use text)?',
}],
actions: data => {
actions: (data) => {
// Generate index.js and index.test.js
const actions = [{
type: 'add',

View File

@ -11,7 +11,7 @@ module.exports = {
name: 'name',
message: 'What should it be called?',
default: 'Form',
validate: value => {
validate: (value) => {
if ((/.+/).test(value)) {
return componentExists(value) ? 'A component or container with this name already exists' : true;
}
@ -44,7 +44,7 @@ module.exports = {
default: true,
message: 'Do you want i18n messages (i.e. will this component use text)?',
}],
actions: data => {
actions: (data) => {
// Generate index.js and index.test.js
const actions = [{
type: 'add',

View File

@ -10,7 +10,7 @@ module.exports = {
name: 'language',
message: 'What is the language you want to add i18n support for (e.g. "fr", "de")?',
default: 'fr',
validate: value => {
validate: (value) => {
if ((/.+/).test(value) && value.length === 2) {
return true;
}

View File

@ -33,7 +33,7 @@ module.exports = {
type: 'input',
name: 'component',
message: 'Which component should the route show?',
validate: value => {
validate: (value) => {
if ((/.+/).test(value)) {
return componentExists(value) ? true : `"${value}" doesn't exist.`;
}
@ -45,7 +45,7 @@ module.exports = {
name: 'path',
message: 'Enter the path of the route.',
default: '/about',
validate: value => {
validate: (value) => {
if ((/.+/).test(value)) {
return true;
}
@ -56,7 +56,7 @@ module.exports = {
// Add the route to the routes.js file above the error route
// TODO smarter route adding
actions: data => {
actions: (data) => {
const actions = [];
if (reducerExists(data.component)) {
data.useSagas = sagasExists(data.component); // eslint-disable-line no-param-reassign

View File

@ -82,4 +82,4 @@ module.exports = (options) => ({
},
devtool: options.devtool,
target: 'web', // Make web variables accessible to webpack, e.g. window
});
});

View File

@ -158,4 +158,4 @@ function templateContent() {
dllNames.forEach((dllName) => body.append(`<script data-dll='true' src='/${dllName}.dll.js'></script>`));
return doc.toString();
}
}

View File

@ -1,7 +1,8 @@
// Important modules this config uses
const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
// const OfflinePlugin = require('offline-plugin');
const pkg = require(path.resolve(process.cwd(), 'package.json'));
const pluginId = pkg.name.replace(/^strapi-/i, '');
@ -20,8 +21,8 @@ module.exports = require('./webpack.base.babel')({
output: {
filename: '[name].js',
chunkFilename: '[name].[chunkhash].chunk.js',
publicPath: 'http://localhost:1337/settings-manager/',
assetsPublicPath: '/settings-manager/',
// publicPath: 'http://localhost:1337/settings-manager/',
publicPath: '/settings-manager/',
},
// We use ExtractTextPlugin so we get a seperate SCSS file instead
@ -46,13 +47,10 @@ module.exports = require('./webpack.base.babel')({
async: true,
}),
// OccurrenceOrderPlugin is needed for long-term caching to work properly.
// See http://mxs.is/googmv
new webpack.optimize.OccurrenceOrderPlugin(true),
// Merge all duplicate modules
new webpack.optimize.DedupePlugin(),
// Minify and optimize the JavaScript
new webpack.optimize.UglifyJsPlugin({
compress: {
@ -60,7 +58,48 @@ module.exports = require('./webpack.base.babel')({
},
}),
// Extract the CSS into a seperate file
new ExtractTextPlugin('[name].[contenthash].css'),
// Minify and optimize the index.html
new HtmlWebpackPlugin({
template: 'app/index.html',
minify: {
removeComments: true,
collapseWhitespace: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeStyleLinkTypeAttributes: true,
keepClosingSlash: true,
minifyJS: true,
minifyCSS: true,
minifyURLs: true,
},
inject: true,
}),
// Put it in the end to capture all the HtmlWebpackPlugin's
// assets manipulations and do leak its manipulations to HtmlWebpackPlugin
// new OfflinePlugin({
// relativePaths: false,
// publicPath: '/',
//
// // No need to cache .htaccess. See http://mxs.is/googmp,
// // this is applied before any match in `caches` section
// excludes: ['.htaccess'],
//
// caches: {
// main: [':rest:'],
//
// // All chunks marked as `additional`, loaded after main section
// // and do not prevent SW to install. Change to `optional` if
// // do not want them to be preloaded at all (cached only when first loaded)
// additional: ['*.chunk.js'],
// },
//
// // Removes warning for about `additional` section usage
// safeToUseOptionalCaches: true,
//
// AppCache: false,
// }),
],
});

View File

@ -245,11 +245,13 @@
"expect": "1.20.2",
"expect-jsx": "2.6.0",
"exports-loader": "0.6.3",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "0.9.0",
"html-loader": "0.4.4",
"html-webpack-plugin": "2.24.0",
"image-webpack-loader": "2.0.0",
"imports-loader": "0.6.5",
"isparta": "^4.0.0",
"json-loader": "0.5.4",
"karma": "1.3.0",
"karma-chrome-launcher": "2.0.0",
@ -274,6 +276,7 @@
"postcss-reporter": "^2.0.0",
"pre-commit": "1.1.3",
"psi": "2.0.4",
"react-addons-test-utils": "^15.4.0",
"rimraf": "2.5.4",
"sass-loader": "^4.0.2",
"shelljs": "0.7.5",

View File

@ -11,7 +11,7 @@ const divider = chalk.gray('\n-----------------------------------');
const logger = {
// Called whenever there's an error on the server we want to print
error: err => {
error: (err) => {
console.error(chalk.red(err));
},