Answer the question
In order to leave comments, you need to log in
How to run webpack config file written in ES6?
webpack.config.js
import Config, { enviroment } from 'webpack-config';
enviroment.setAll({
env: () => process.env.NODE_ENV
});
export default new Config().extend('config/webpack.[env].config.js');
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-register": "^6.26.0",
"html-webpack-plugin": "^2.30.1",
"webpack": "^3.6.0",
"webpack-config": "^7.4.0"
},
"scripts": {
"build-dev": "set NODE_ENV=development && webpack --progress",
"build-prod": "set NODE_ENV=production && webpack --progress"
}
Answer the question
In order to leave comments, you need to log in
I found a solution.
I added the line
alias: {
jquery: require.resolve('jquery'),
},
resolve: {
modulesDirectories: ['node_modules'],
extensions: ['.js', ''],
alias: {
jquery: require.resolve('jquery'),
},
},
import 'paroller.js';
$(document).ready(() => {
$('.js-box').paroller({
factor: 0.5,
factorXs: 0.2,
type: 'foreground',
direction: 'horizontal',
});
});
The node does not know how to import yet. So either use modules that allow such code (and they exist), or use the usual require.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question