Closed tangsj closed 6 years ago
When used in webpack, the folder name where jquery.mCustomScrollbar.min.css is placed must not contain malihu-custom-scrollbar-plugin. This will not use the imports-loader to load, and use css-loader to load
doing like this, working well !! {test: /jquery-mousewheel/, loader: "imports-loader?define=>false&this=>window"}, {test: /malihu-custom-scrollbar-plugin\/**\/*.js/, loader: "imports-loader?define=>false&this=>window"}, { test: /.css$/, use: ExtractTextPlugin.extract({ fallback: "style-loader", use: "css-loader" }) }, { test: /.(png|svg|jpg|gif)$/, use: [ 'file-loader' ] }
in my index.js use:
import 'malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.css';
build Error:
ERROR in ./node_modules/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.css Module build failed: ReferenceError: window is not defined
my webpack build config:
{ test: /jquery-mousewheel/, loader: "imports-loader?define=>false&this=>window" }, { test: /malihu-custom-scrollbar-plugin/, loader: "imports-loader?define=>false&this=>window"},
{ test: /.css$/i, use: ExtractTextPlugin.extract({ fallback: 'style-loader', use: [ { loader: 'css-loader', options: { sourceMap: true, }, }, { loader: 'postcss-loader', }, ], }), },