Unexpected token You may need an appropriate loader to handle this file type.importing strapi sdk
Unexpected token You may need an appropriate loader to handle this file type.importing strapi sdk
Hi I am trying to import javascript strapi sdk (link) in my new project which is configured using web pack
Here is my code yet
index.ts file
import * as $ from 'jquery';
import Strapi from 'strapi-sdk-javascript'
const strapi = new Strapi('http://localhost:1337')
here is my webpack.config.file
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const webpack = require('webpack');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
module.exports =
entry: './src/index.ts',
module:
rules: [
test: /.js$/,
use:
loader: 'babel-loader',
options:
presets: ['env']
,
// include: [path.resolve(__dirname, "./src/app")],
exclude: /node_modules/
]
,
resolve:
extensions: ['.tsx', '.ts', '.js'],
alias:
$: "jquery/src/jquery",
,
devtool: 'inline-source-map',
devServer:
contentBase: './dist'
,
plugins: [
new CleanWebpackPlugin(['dist']),
new HtmlWebpackPlugin(
template: 'src/assets/template.html'
)
],
output:
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist')
;
and this is giving my this error
what am i doing wrong here . please
help thanks in advance
1 Answer
1
You can try something like this
// Process JS with Babel.
mjs)$/,
include: [path.resolve(__dirname,"./src/app")path.resolve('node_modules/strapi-sdk-javascript')],
loader: require.resolve('babel-loader'),
,
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
not working still :(
– Asad
Sep 6 '18 at 22:07