Jump to content

PS 1.7 : Module not found: Error: Can't resolve 'tablednd/dist/jquery.tablednd.min'


Recommended Posts

Bonjour,

Je suis en train d'ecrire un module avec des 'grid' et j'ai un soucis en compilant les js quand j'importe le fichier position-extended.js :

Module not found: Error: Can't resolve 'tablednd/dist/jquery.tablednd.min'

Dans le source j'ai modifié l'import du fichier jquery.tablednd.min en :

import tableDnD from "../../../../../../../js/jquery/plugins/jquery.tablednd";

Mais cela ne me satisfait pas pleinement.

Dois je moi même ajouter les fichiers manquant à l'admin de prestashop ou tout simplement je m'y suis mal pris pour créer mes js (pb config webpack ?, mauvais import) ?

config webpack

/**
 * 2007-2018 PrestaShop
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * https://opensource.org/licenses/OSL-3.0
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to [email protected] so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
 * versions in the future. If you wish to customize PrestaShop for your
 * needs please refer to http://www.prestashop.com for more information.
 *
 * @author    PrestaShop SA <[email protected]>
 * @copyright 2007-2018 PrestaShop SA
 * @license   https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
 * International Registered Trademark & Property of PrestaShop SA
 */

const path = require('path');
const webpack = require('webpack');
//const keepLicense = require('uglify-save-license');
//const regenerator = require('@babel/plugin-transform-runtime')

const config = {
    entry: {
        grid: [
            './js/grid',
        ]/*,
        form: [
            './js/form',
        ]*/
    },
    output: {
        path: path.resolve(__dirname, 'public'),
        filename: '[name].bundle.js'
    },
    //devtool: 'source-map', // uncomment me to build source maps (really slow)
    resolve: {
        extensions: ['.js']
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                include: path.resolve(__dirname, 'js'),
                use: [{
                    loader: 'babel-loader',
                    options: {
                        presets: [
                            '@babel/preset-env',
                            //['es2015', { modules: false }]
                        ],
                        plugins: [
                            //'@babel/plugin-transform-runtime'
                        ]

                    }
                }]
            },
            {
                test: /\.js$/,
                include: path.resolve(__dirname, '../../../admin-dev/themes/new-theme/js'),
                use: [{
                    loader: 'babel-loader',
                    options: {
                        presets: [
                            ['es2015', { modules: false }]
                        ]
                    }
                }]
            }
        ]
    },

    resolveLoader: {
        // Configure how Webpack finds `loader` modules.
        modules: [
            '/usr/lib/node',
            path.resolve(__dirname, 'node_modules'),
            '/usr/local/lib/node_modules/npm/node-modules',
        ],

    },
    plugins: [

    ]
};

if (process.env.NODE_ENV === 'production') {
    config.plugins.push(
        new webpack.optimize.UglifyJsPlugin({
            sourceMap: false,
            compress: {
                sequences: true,
                conditionals: true,
                booleans: true,
                if_return: true,
                join_vars: true,
                drop_console: true
            },
            output: {
                comments: keepLicense
            }
        })
    );
} else {
    config.plugins.push(new webpack.HotModuleReplacementPlugin());
}

module.exports = config;

 

Le fichier à compiler :

/**
 * 2007-2018 PrestaShop
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * https://opensource.org/licenses/OSL-3.0
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to [email protected] so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
 * versions in the future. If you wish to customize PrestaShop for your
 * needs please refer to http://www.prestashop.com for more information.
 *
 * @author    PrestaShop SA <contact@prestashop.com>
 * @copyright 2007-2018 PrestaShop SA
 * @license   https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
 * International Registered Trademark & Property of PrestaShop SA
 */

import Grid from '../../../../../admin766tkbzl0/themes/new-theme/js/components/grid/grid';

import SortingExtension from "../../../../../admin766tkbzl0/themes/new-theme/js/components/grid/extension/sorting-extension";
import LinkRowActionExtension from '../../../../../admin766tkbzl0/themes/new-theme/js/components/grid/extension/link-row-action-extension';
import SubmitRowActionExtension from '../../../../../admin766tkbzl0/themes/new-theme/js/components/grid/extension/action/row/submit-row-action-extension';
import PositionExtension from "../../../../../admin766tkbzl0/themes/new-theme/js/components/grid/extension/position-extension";

import FiltersResetExtension from '../../../../../admin766tkbzl0/themes/new-theme/js/components/grid/extension/filters-reset-extension';
import ReloadListActionExtension from '../../../../../admin766tkbzl0/themes/new-theme/js/components/grid/extension/reload-list-extension';
import ColumnTogglingExtension from '../../../../../admin766tkbzl0/themes/new-theme/js/components/grid/extension/column-toggling-extension';
import SubmitBulkExtension from '../../../../../admin766tkbzl0/themes/new-theme/js/components/grid/extension/submit-bulk-action-extension';
import BulkActionCheckboxExtension from '../../../../../admin766tkbzl0/themes/new-theme/js/components/grid/extension/bulk-action-checkbox-extension';
import ExportToSqlManagerExtension from '../../../../../admin766tkbzl0/themes/new-theme/js/components/grid/extension/export-to-sql-manager-extension';


const $ = window.$;

$(() => {
  let gridDivs = document.querySelectorAll('.js-grid');
  gridDivs.forEach((gridDiv) => {
      const dureeBlockGrid = new Grid(gridDiv.dataset.gridId);

      dureeBlockGrid.addExtension(new SortingExtension());
      dureeBlockGrid.addExtension(new LinkRowActionExtension());
      dureeBlockGrid.addExtension(new SubmitRowActionExtension());
      dureeBlockGrid.addExtension(new PositionExtension());

      dureeBlockGrid.addExtension(new ExportToSqlManagerExtension());
      dureeBlockGrid.addExtension(new ReloadListActionExtension());

      dureeBlockGrid.addExtension(new FiltersResetExtension());
      dureeBlockGrid.addExtension(new ColumnTogglingExtension());
      dureeBlockGrid.addExtension(new SubmitBulkExtension());
      dureeBlockGrid.addExtension(new BulkActionCheckboxExtension());
  });
});

Merci d'avance pour vos réponses

PYT

 

 

 

 

 

Link to comment
Share on other sites

  • 4 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...